[quote name='swilkewitz' timestamp='1306940984' post='4818293']
I am using the pointers to create a hierarchy of unrelated classes. The pointers would create a sort of "spine."
Game
>World
>Actor
A Game would hold an instance of World, and a World would hold a pointer of Game. So when Game is being constructed I want to create a World and set the World's pointer to the Game.
I thought that using the "this" pointer would work fine, but I wasn't able to get the "spine" working.
... gd.net reformatted puke elided ...
I know the first one is wrong, I never tried to do that. The second way is how I've been getting around the problem... though I've been passing &owner instead of owner.
So, what's the problem? That's fairly idiomatic.
World::World()
: game(this)
{ }
Game::Game(World* world)
: actor(world)
{ }
[/quote]
That is what I tried to do originally, but when I called higher-up functions using the pointers nothing happened. By using the workaround the pointers work, but I'd rather not use the workaround because that doesn't actually solve the problem.
Also, I'm getting memory problems now. I've been experimenting a lot....
When I start my game in debug mode everything is fine, but when I switch to release mode eveything goes haywire. I looked at taskmanager while running in release and I noticed the used memory cycling between 1.5 GB and 2.5 GB before crashing.
Unhandled exception at 0x768bb727 in Triax Bridge Command.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0035ed40..
I'm guessing I'm not being very careful with my pointers.