Doubling the size of a stack

Hello, I am writing a function that takes a stack and doubles the size of it and copies the old information from the original stack to the new one. The stack is implemented with a dynamic array. I receive a compiler error and believe that the error lies with this function.

1
2
3
4
5
6
7
8
9
10
11
12
	void growStack(int newCapacity)  
	{
		double * temp=NULL;
		for(int i=0;i<=capacity;i++)
		{temp[i]=s[i];}

		s = new double[newCapacity];
		s=temp;

		this->capacity=newCapacity;
		delete[]temp;	
	}
Topic archived. No new replies allowed.