Let's say that I have this
#define T 10
StackOverflow *_stObject[H];
How can I "resize" this array to 20? I cannot use vectors. I have to copy that 11 positions to another array of pointers with 20 positions, but that way I will cannot use this object in my other functions.
This object stores data, and when it gets full I need to find a way to continue to add data.
How can I do this?
Ok here it is some more information because it's not working. I made the method extendArray() but it have an error when I make r = temp
This is a calculator and the class Reg stores the information the operation that I make in the calculator. The object "r" stores 10 operations and I have to expand this array of pointers if I make more than 10 operations.
The error message that I get is in r = temp and it says: incompatible types in assignment of 'Reg* [20]' to 'Reg* [10]'|
#define T 10
class Calculator
{
public:
Calculator();
Calculator(NumComp&,NumComp&);
~Calculator();
void printVisor();
void setCalculator(const NumComp&,const NumComp&);
void menu();
void help();
void clean();
void run();
void extendArray();
private:
NumComp n1, n2;
Reg *r[T];
int _tMax;
};
void Calculator::extendArray()
{
Reg *temp[T*2];
for(int i = 0; i < 5; i++){
temp[i] = new Reg;
temp[i] = r[i];
delete r[i];
}
r = temp;
_tMax *= 2;
}