Jump to content
  • Advertisement
Sign in to follow this  
D3DXVECTOR3

Need help with #includes

This topic is 4836 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

I have been programming C/C++ for 3 years now and I thought that I had most things under controle, I was wrong :(
// DXDFont.h
#ifndef _DXFONT_H_
#define _DXFONT_H_

class DXFont
{

};

#endif


// CConsole.h
#ifndef _CCONSOLE_H_
#define _CCONSOLE_H_

#include "DXFont.h"

class CConsole : public DXFont
{


};

#endif

As you can see I have the the "MyClass.h" included but I found out that the problem is that at the time NewClass is build MyClass hasnt thus the error. So im guessing that I have something wrong with how I include my headers or something. My precompiled header is set to "Automatically Generate (/YX)". [Edited by - D3DXVECTOR3 on August 25, 2005 4:23:36 PM]

Share this post


Link to post
Share on other sites
Advertisement
I actually think your error has nothing to do with includes.
Change
class NewClass : MyClass
in
class NewClass : public MyClass
and you're fine.

Share this post


Link to post
Share on other sites
public or private inheritance shouldn't matter in this case. The best thing you can do is show some real code. In particular do have the base class header include the new class header?

Share this post


Link to post
Share on other sites
That's an interesting way of setting up your inclusion guards, and I don't think it would necessarily work the way you want it to.

In your NewClass.h file (the one you show us), you have "#ifndef _MYCLASS_H_"/"#define _MYCLASS_H_"/"#endif" around it, where you would probably be better off having them in your MyClass.h file, and _NEWCLASS_H_ versions for this file.

However that would only be causing your problem if you did indeed already have the _MYCLASS_H_ version in MyClass.h.

Hope that helps,
Twilight Dragon

Share this post


Link to post
Share on other sites
Well, it worked fine for me...

Ergo, the problem is not to do with the way you handle inclusions, which is from what you've shown so far quite correct. What is the actual error you get?

Share this post


Link to post
Share on other sites
lol I dont know where I left my brains, i making alot of errors here. anyway the error im getting is: CConsole.h: error C2504: 'DXFont' : base class undefined

I cant post the more code because that would be 2 much. all I can add is that both DXFont and CConsole are includes by other classes (not inherited though). I have all the classes like these (ifndef's)
I noticed that Visual Studio bluids in aphabetical order and CConsole come for DXFont.

Share this post


Link to post
Share on other sites
This is probably a massively inaccurate shot in the dark, but one time I was copy and pasting (yes I know, I'm a horrible person) and forgot to change the #include guard for a second file so the first file never got compiled and I got weird errors about things not being defined that should have been.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!