Archived

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

Array within a Class

This topic is 6284 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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