Dim
Mar 1st, 2002, 02:10 AM
k i'm basically replicating the vector class.
I have ALOT of code which uses the fixed array of 10 elements. I have two classes being used also. The dynamic array would be used in a class.
So so far this is what i have for the fixed Private section of the class:
static const int MAX = 10;
T data[MAX];
and then within the class implementation, i have numersoun functions that use this array. My question is: wat would be the easiest way to convert this class to a dynamic array.
Would i change the above code to:
static int MAX = 10;
T *data;
and then would i have to sort through the class and wherever there is an element being added to the erray i would check for the current size of the array and if it's too small i would use the 'new' to increase the size of the array?
T *data = new T(MAX + 10);
would taht work?
Someone please help, there is just SO much code that i can't figure this out.
Thanx,
D!m
PS. Sorry for the length.
I have ALOT of code which uses the fixed array of 10 elements. I have two classes being used also. The dynamic array would be used in a class.
So so far this is what i have for the fixed Private section of the class:
static const int MAX = 10;
T data[MAX];
and then within the class implementation, i have numersoun functions that use this array. My question is: wat would be the easiest way to convert this class to a dynamic array.
Would i change the above code to:
static int MAX = 10;
T *data;
and then would i have to sort through the class and wherever there is an element being added to the erray i would check for the current size of the array and if it's too small i would use the 'new' to increase the size of the array?
T *data = new T(MAX + 10);
would taht work?
Someone please help, there is just SO much code that i can't figure this out.
Thanx,
D!m
PS. Sorry for the length.