![]() |
|
Inheritance issues - Printable Version +- iDevGames Forums (http://www.idevgames.com/forums) +-- Forum: Development Zone (/forum-3.html) +--- Forum: Game Programming Fundamentals (/forum-7.html) +--- Thread: Inheritance issues (/thread-3239.html) |
Inheritance issues - Tekkan - Jun 13, 2007 06:29 PM I have run into a ridiculously frustrating problem that I feel there must be a basic solution to. Basically, say I want two classes to extend the same base class, but each class has its own .cpp and .h files. If I try to include both of the child class' header files, I get an error saying that I'm trying to redefine the base class. This is a shortened down version of what I'm trying to do: AnimateObject.h: Code: struct StatePlayer.h: Code: #include "AnimateObject.h"Enemy.h: Code: #include "AnimateObject.h"Now in main.cpp, I obviously want to be able to create both a Player and an Enemy object, but I can't, because if I try: Code: #include "Player.h"I get an error stating "previous redefinition of struct State" and "previous redefinition of class AnimateObject". There has to be a simple way around this, right? Inheritance issues - OneSadCookie - Jun 13, 2007 06:34 PM Code: #ifndef MyHeaderNameInheritance issues - Cochrane - Jun 16, 2007 02:01 AM Code: #pragma onceInheritance issues - Tekkan - Jun 16, 2007 06:30 PM Thanks, guys. Google had failed me with this information. |