Archived

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

Negitivefrags

Inheritance problem driving me up the wall

Recommended Posts

I seem to be having trouble deriving one class from another. I have a .h file which includes all of the other headers in the project. There is a header file which has a base class in it. I have another header file with a class that is derived from the other. However, when I compile it says "Base class declared but not defined" Now the only place in the project where the class is declared is the same place that it is defined, so how could I posibly get this error? I have tryed including the the file with the base class directly into the file with the derived class. I have scoured the code for missing semicolons and spelling errors. The only thing that seems to work is copying the derived class into the same file as its base. Can anyone think of any suggestions?

Share this post


Link to post
Share on other sites
Whatever you do, don''t copy the source into the base class. Everytime you do that you let the crappy compiler demons win

What I suggest is try commenting out the code that says "INHERIT THIS!", and if you still get errors (except for those from the class accessing base class material), then you know it is not the problem the compiler is telling you it is.

If you do indeed find out its not the definition error its giving you, just start commenting code until you find the line that contains the problem.

Share this post


Link to post
Share on other sites
Well, its seems to be working now.

I must have made a mistake *somewhere* before becuase the way I fixed it was to redo all of the includes for the entire project from scratch. (Actuly it was a good excuse to clean up a lot a worthless ones that have built up)

Having said that, this sort of thing seems to be really common. I get this sort of thing all the time and it is often fixed by shuffling around the order of the includes, or in one case, the order of the meathods in a class (dont ask me what that was about), or somthing else equaly as trivial.

Share this post


Link to post
Share on other sites
To do what you intended to do, you should use the ''export'' keyword.
e.g.: export template myTemplate{/*..*/};

Share this post


Link to post
Share on other sites
This is usually caused by circular includes. Next time, look for that before you do everything over.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites