void dynArray::doubleSize( )
{
size = 4;
int *temparray;
int currentsize = size;
int newsize = currentsize * 2;
temparray = newint[newsize];
for (int i = 0 ; i < newsize;i++)
{
temparray[i] = list[i];
}
size = newsize;
delete [] list;
list = newint[size];
list = temparray;
// this it help see if i made any changes
cout << sizeof(temparray) << "temp size:\n";
cout << sizeof(list) << "list size:\n";
cout << size << "new size:\n\n\n";
}
I want it to output the size of array is the function each time it changes size.I know this can be done with vectors but I would like to understand how to do it with arrays
sizeof applied to a pointer is the size of a pointer, not the size of whatever is pointed to. That cannot be obtained via a language construct. You must keep track of it yourself.