Quote:Original post by cannonicus
This is NOT for homework. We dont event not what a heap is in my class, and i doubt thats even part of our cours.
Anyways, im working on a sidescroller lierostyle game. This heap-only class is to be used in my sprite-baseclass so that sprite classes wont be created before the main function. DirectX would in that case not have been loaded properly and the sprites, trying to create dx-surfaces, would cause errors when trying to use directx without a directx-interface.
Maybe(probably) theres another better way solve this problem, like haveing all dx-dependent code in a separate sprite function called in the main-loop instead of haveing it in the constructors. But it is always best to ask...
Feedback plz.
From your description thye problem has nothing to do with where the memory is allocated, but simply WHEN it is allocated.
If it must be allocated after DX then all you have to do is dynamically allocate it after your DX stuff. i.e. don't make the objects themselves global, instead have a global pointer to them. I don't see why it's so hard to solve, unless there's something I'm missing?