OO Design Question

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: OO Design Question

Post 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;
};
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
Maevik
Chaos Rift Junior
Chaos Rift Junior
Posts: 230
Joined: Mon Mar 02, 2009 3:22 pm
Current Project: www.keedepictions.com/Pewpew/
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: Long Beach, CA

Re: OO Design Question

Post 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?
My love is like a Haddoken, it's downright fierce!
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: OO Design Question

Post by MarauderIIC »

Are you #including something in Game.h? Do you #ifndef #define #endif the same things in two different headers?
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Post Reply