Hi,
I am a real beginner, and I am having trouble, can someone please help. I have to complete some code to change the size of an array to a new size (newS) that is specified by the argument in program that tests it. The program that I have to code uses a template and I'm a bit unsure how to go about this. I think I need to use 'new' but not sure how.
I have to complete the code for public function void grow(int);
template <class BType, class IType>
void Array<BType, IType>::grow(int newS)
{
// I need to code this, everthing else is already done
}
The program for testing this is
int main(void)
{
int i;
Array<int> A(5);
ofile.open("A11.out");
for (i = 0; i < 5; ++i)
A[i] = i;
printIt(A, "Original");
A.grow(10);
for (i = 5; i < 10; ++i)
A[i] = 2 * i;
printIt(A, "Increased");
A.grow(4);
printIt(A, "Decreased");
ofile.close();
return 0;
}
Thanks