// 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
Need help with #includes
I have been programming C/C++ for 3 years now and I thought that I had most things under controle, I was wrong :(
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]
I actually think your error has nothing to do with includes.
Change
Change
class NewClass : MyClass
in class NewClass : public MyClass
and you're fine.
thx for the quik reply :)
it looks like i made is little mistake in my post, its alsready has public in front of it
it looks like i made is little mistake in my post, its alsready has public in front of it
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?
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
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
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)
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?
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?
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement