Array of Integers as a class member
I've tried all night to figure this out, and I know I'm just going in circles...
I want to have an array of integers as a private variable of my class and I want to populate it with all zeros.
When I assign and print out the contents in the constructor, everything looks fine, but when I print out the array's contents in another method, I have a bunch of random numbers, rather than what I assigned.
PHP Code:
class myClass
{
public:
myClass();
~myClass();
void PrintContents();
private:
int myArray[32];
};
PHP Code:
myClass::myClass()
{
for ( int i = 0; i < 32; i ++)
{
myArray[i] = 0;
cout << i << " = " << myArray[i] << endl;
}
}
void myClass::PrintContents()
{
for ( int i = 0; i < 32; i ++)
cout << i << " = " << myArray[i] << endl;
}
Any tips or references? I know my array will always be 32 (0-31) size, so I didn't want to use a vector unless there isn't anyway for me to use a simple array.
thanks,