Oh that's great news, I was reading one website that said .bin files don't really like vectors. Is it stable enough to use in games saves for release titles?
Thanks again guys, you've cleared up quite a few things there.
Firstly I was just trying to encapsulate the code as it seemed the natural progression if I were creating objects in objects. Is it wrong to try this kind of nesting? Would I be better off just creating a separate class?
Secondly I was trying to avoid vectors as I thought that you couldn't save them in .bin files. only vars and arrays! Is that a falsehood?
You should only delete what you have created with new.
So for the following line how do I reference back to this object once created? or do I just assign the array slot to zero?
GenObjectClass::mcaTroops[i] = new GenObjectClass::cTroopObj;
Is mcaTroops supposed to be static, meaning it only exists one such array that will stay alive until the end of the program, or do you want each GenObjectClass to have its own mcaTroops array?
Ah I seem to have mistaken the use of static then, I didn't realise it was till program death, I thought it was in the scope of the objects lifespan.
yes, each GenObjectClass to have its own mcaTroops array.
I want an array of nested class objects to be stored in the main class objects array, they are then created and detroyed by the function calls of the class they are nested in.
Just a few last questions, do I need to "delete mcaTroops;" in the destructor? As soon as I use a pointer the memory is allocated on the heap isn't it, will it stay in scope whilst the GenObjectClass object; still exists!
And do I need to declare the object as a pointer to keep it 'alive' (GenObjectClass* object;) within the scope of the main function? deleting that when it is also not needed in the code.