Operation on array - c program, C/C++ Programming

Operation on array:

void Array::add( Object& toAdd )

{

    lastElementIndex++;

    while( ptrAt( lastElementIndex ) != ZERO &&

           lastElementIndex <= upperbound

         )

        lastElementIndex++;

 

    if( lastElementIndex > upperbound )

        reallocate( lastElementIndex - lowerbound + 1 );

 

    setData( lastElementIndex, &toAdd );

    itemsInContainer++;

    CHECK( itemsInContainer > 0 );

}

 

void Array::addAt( Object& toAdd, int atIndex )

{

    PRECONDITION( atIndex >= lowerbound );

    if( atIndex > upperbound )

        reallocate( atIndex - lowerbound + 1 );

 

    if( ptrAt( atIndex ) != ZERO )

        {

        delete ptrAt( atIndex );

        }

 

    setData( atIndex, &toAdd );

}

Posted Date: 10/18/2012 6:12:11 AM | Location : United States







Related Discussions:- Operation on array - c program, Assignment Help, Ask Question on Operation on array - c program, Get Answer, Expert's Help, Operation on array - c program Discussions

Write discussion on Operation on array - c program
Your posts are moderated
Related Questions
to design a car that travels along the room and gives the length of the room

Define Polymorphism? A: Polymorphism let a client to treat distinct objects in the similar way even if they were developed from distinct classes and exhibit different behaviors.

Write an algorithm for multiplication of two sparse matrices using Linked Lists.

(a) Write a recursive procedure (digits n) that computes the number of digits in the integer n using a linear recursive process. For example, (digits 42) should return 2 and (digit



A: Depends. Might be "zero" Objects which are thrown must have a publicly accessible copy-constructor. The compiler is permitted to generate code which copies the thrown object

If an array holds integer, each of which is four bytes long, how many bytes from the base location of the array is the location of the fifth element?

Find out initial basic feasible solution for the given transportation problem using Least Cost Method (LCM).

Which constructor gets called while I create an array of Fred objects?