Thank you, but if I created a different array, it wouldn't have the same name, unless I created a temporary array, released the first one, then recreated it and recopied.
But then I would have to make and overload a function for every class, and I was hoping there is an easier way (besides using the C libraries)
Due to an abominable oversight in the design of C++, there is no renew operator. Therefore you will either have to allocate a new one and copy it in, use malloc instead of new, or use a vector instead of an array.
Simply, you invoke the class member method myClass & resize();
which returns reference to it-self (as i have shown in the previous post). You could invoke this function from anywhere as long as you are in the scope of myClass. -TAZO
realloc() will not work if myClass is not trivially-copyable (say, it has a string or a vector member or has a nontrivial copy constructor). This is C++, use vectors by default.
I'm sorry bluecoder, I don't understand what you mean by saying:
assign the return class by the function resize() ;
If you are referring to the return type of the member function resize(); being myClass & what you will need to return is the "this" pointer which is already created by the run time of your program. When you have class in you program "this" pointer will point your data & method members. When you return "this" basically you are returning the location of you function member.
Now, you could also make your function returning type "void" instead of "reference to self", but then you can't chain your function.