PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Initialising variables using new & referencing them

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'
Conan · 03 Nov 2002, 19:00 UTC — Thanks to BurningSheep
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 :)
HTK · 14 Dec 2002, 16:47 UTC — space? bring it on!
Hey Conan, when are we going to see a demo? :D
Conan · 15 Dec 2002, 10:37 UTC — seeing a demo ?
Having a full time job means that I write slowly and because I write full sized games it always takes me a year or so to finish one.

At present the mixed 2D/3D game engine is working fine and I'm going through tests with a graphics artist for the 2nd time as the first artist pulled out due to the prospect for some quick money.

I'm guessing late summer 2003.

(this game is really just a way of finishing off my C++ learning so the next game which I'm already planning will be quicker)