Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Header problem

This topic is 6202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!