Header problem

Started by
1 comment, last by Impz0r 22 years, 8 months ago
y00, i''ve some stupid question *g*, ok i would explain my fault i''ve 2 headers, number one : cObject.h number two : cRenderer.h first cObject.h class cObject { cObject(){} ~cObject(){} Draw(cRenderer *pRenderer) { // check for frustum culling and so pRenderer->Draw(this); } } ok and then number two the cRenderer.h i declare my abstract render interface like this stupid one // keep in mind this is only to explain my fault :D class cRenderer { cRenderer(){} ~cRenderer(){} virtual VOID Draw(cObject *pObject)=0; // this is where is start to have fun *g* } ok i hope you understand the above shit *g* wenn i want to compile my project in on of the both headers he stopped and tell me he can''t found the cObject class or the cRenderer class, this is why every of the both headers have include the other one, but how would this work for me??? if you know a way out of my situation let me know it pls thx :D Imp bugs are uncommented features...
Stay Evil & Ugly!
Advertisement
The problem is that both of your classes use and depend on the other class mutually, but you are using them even though they are both unfamiliar with each other.

I would suggest hiding just the class declarations in their own header files, and doing something like this:

(In cObject.h)

class cRenderer;

class cObject {
};

(In cRenderer.h)

class cObject;

class cRenderer {
};

Now make .cpp files for each of these that include their corresponding .h and define the functions. This is called a forward declaration, but you can''t include your functions in the .h because it is simply saying that one name like cObject is a class. It isn''t saying it has special properties, functions, etcetera that your functions will require.

So try this out, and see if it gets you anywheres. Good luck.
"The time has come", the Walrus said, "To speak of many things."
well :D

Thank you sympathy your solution works well for me

thx Imp

Stay Evil & Ugly!

This topic is closed to new replies.

Advertisement