Archived

This topic is now archived and is closed to further replies.

Prairie

Array within a Class

Recommended Posts

Prairie    122
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

Share this post


Link to post
Share on other sites
acraig    471
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

Share this post


Link to post
Share on other sites