I'm afraid I've gone stupid. Array question.

ohio_wookie

Registered
ok so I'm about to become a senior in Game and Simulation Engineering and I've gone done forgot a simple thing with arrays. doh! Its not so bad, I have been doing a lot of STL stuff. Anyway.

How do you initialize an array after you've declared it in C++, I want a outcome similar to:

class blahblah
private:
thisarray[4];
public:
blahblah()
thisarray[] = {0,1,2,3};

now obviously that doesnt work. how do i actually do it?

-Crash
 
class blahblah {
private:
int thisarray[];
public:
blahblah()
};

.
.
.
// In a 'Constructor', etc. (where applicable), ...
for ( n=0 ; n<4 ; n++ ){thisarray[n] = n;}
 
thanks for the help, I figured it out.
you can't initialize in private, that was my problem.

I just have to do it the long way of
thisarray[0] = 0;thisarray[1] = 1; thisarray[2] = 2; thisarray[3] = 3;
 
Back
Top