Page 2 of 2

Re: OO Design Question

Posted: Thu Apr 09, 2009 12:30 pm
by MarauderIIC
Did you spell Renderer right in your class definition? Also, caps matters. Essentially it's saying that it has no idea what "Renderer" is. Another possible problem is that maybe you missed a semicolon in renderer.h or any include file of yours that is included in renderer.h. Since it comes and goes and compile order is arbitrary I would think that it would be something like this second one.

Also, re "Is there something special I need to do when making a class a member of another class?"
No. But, if you're just using a pointer, you can save recompile time by declaring a class prototype, say,

Code: Select all

class Renderer;

class MyClass {
    Renderer* renderer;
};
This means that if you change something in renderer.h you won't have to recompile all the files that #include myclass.h. In other words, it limits the ripple effect of changing a header.

But if you declare it as a non-pointer, you have to

Code: Select all

#include "renderer.h"

class MyClass {
    Renderer renderer;
};

Re: OO Design Question

Posted: Fri Apr 10, 2009 4:38 pm
by Maevik
Thanks, I'm still not quite to the bottom of it, but I'm close. If I remove #include "Game.h" from the Renderer.h code, it compiles fine, and it wont if I add it back in. This is pretty consistant and I've tried many times. The thing that still baffles me is that I've gone over the code in Game.h a hundred times and I can't find a misspelling or a missing semicolon anywhere. Anything else that might be causing it?

Re: OO Design Question

Posted: Fri Apr 10, 2009 5:32 pm
by MarauderIIC
Are you #including something in Game.h? Do you #ifndef #define #endif the same things in two different headers?