Ive done this in java by setting the array = new array[bigger number here](or something to that effect) how does one do this in c++? This should accomplish erasing the data in ary that exists, and essentially starting over with the variable.
It should be pointed out that im doing a circular array (queue) and in my header file for the class, I have the following:
private: int front; int back; int ary[];
in my constructor i have the following:
queuei::queuei(){
// basic constructor;
front=-1;
back=-1;
int ary = new int[10]; // this is what i want to do, i know the syntax is wrong...
}
in the end, the idea is to reuse the same variable name. Later on I make a new array, copy everything over to it with a bigger size, reallocate "ary" and copy everything back to avoid using a new variable name.
I know I can use vectors, but im in a class, and this is part of the assignment.
thanks
This post has been edited by NecroWinter: 08 April 2012 - 09:39 PM

New Topic/Question
Reply




MultiQuote





|