Public Group

# Need help with #includes

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

## 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 on other sites
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 on other sites
thx for the quik reply :)
it looks like i made is little mistake in my post, its alsready has public in front of it

##### 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 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 on other sites
ahm man so many errors in my post. Oke i edited it into the real source (removed functions etc to make it easy to read)

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

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 10
• 9
• 34
• 16
• ### Forum Statistics

• Total Topics
634125
• Total Posts
3015666
×