Advertisement

Array within a Class

Started by October 03, 2000 11:12 AM
0 comments, last by Prairie 24 years, 3 months ago
I have an array in a class. I want to give the array a depth dependant on a variable passed to the constructor. I''ve tried "new" and all sorts of other things and nothing is working. If anyone can guide me in the right direction, or even suggest an alternative way to do it, it would be greatly appreciated. Thanks; Prairie
Not really enough information here to figure out exactly what you are doing but here we go:

    class IHaveAnArray{	public: 		IHaveAnArray(int arraySize)	{		myInternalArray = new int[arraySize];		// check error	}		~IHaveAnArray()	{		delete[] myInternalArray;	}	private:	int *myInternalArray;};    





Edited by - acraig on October 3, 2000 12:44:36 PM

This topic is closed to new replies.

Advertisement