Page 1 of 1

Initialising variables using new & referencing them

PostPosted: Nov 3, 2002 @ 7:29pm
by Conan
BurningSheep was helping me solve a memory issue. I was using up the stack instead of utilising the heap(I think)
All my variable definitions plus the structs which were giving me problems are in a MyGame.h file containing the definition of the MyGame class, all the function prototypes and variable definitions.

I cannot put the following line in this section
planet_data *planets = new planet_data[2000]; as I can only define the variables not give them a value. I get error C2258: illegal pure syntax, must be '= 0'
If I put the new statements in the MyGame init function then other functions cannot access them.

My code is split across various source files as eventually the game will be very big & I can;t keep it inside one source. This may have something to do with it.

Up till now I was manageing by creating the variable in the MyGame.h & giving it a value in the init function but I don;t see how to do this with 'new'

Thanks to BurningSheep

PostPosted: Nov 3, 2002 @ 8:00pm
by Conan
My usage of new had a bug which is now solved thaks to BurningSheep. I hope you like space strategy games so I can give you a free registration :)

space? bring it on!

PostPosted: Dec 14, 2002 @ 5:47pm
by HTK

seeing a demo ?

PostPosted: Dec 15, 2002 @ 11:37am
by Conan