   [C++] Multiple Inheritance and polymorphism
  Hi, I am trying to right my own c++ 2D game engine and am kinda stuck right now.My base engine class can play "state class" representing for example the menu state, a play state, etc..... At the beginning everything was simple, every Custom State class inheriting from my base State class.But now the design changed a bit and most of my custom  State class inherit from a PhysicState class that inherit from the base State classso it was  State -> CustomStateand now its  State -> PhysicState -> CustomStateTHEN i remember....you can't do polymorphism on 2 "layer" in C++Is there any pattern to achieve this ??? Using Virtual inheritance or Interface ?   
  1) You *can* have polymorphism over 2 layers like that.2) That's not multiple inheritance. Multiple inheritance is when CustomState inherits from both PhysicState and State directly (instead of CustomState inheriting from PhysicState, which then inheritrs from State).   ;  I need to do something like this in the code somewhereState* aState = new MyCustomState();and it keep telling me that State is an unreachable parent of MyCustomState   ;  You've probably forgotten the word public when you specify your parent class ;)e.g. MyCustomState : public PhysicsStateor PhysicsState : public StateEasy mistake to make, and the compiler error isn't very helpful unless you've come across this problem before.   ;  hum....when i test it.....polymorphism effectively work on more than one level, i was told not from somebody and I trusted him without testing..... However.... I still have the problem even with the public keyword (it was already there). The design is a bit blurry right now, I will start by clean the mess then I'll see.Thanks for the help ( I mean....I won't try a crazy hack to get around a non-existent problem now.....lol)   ;  Got it, I feel stupid right now, lol it was a namespace problem..... I'll try to keep my code cleaner and don't trust to everything in the future :-P.Thanks!   ;Quote:Original post by twistedjoehum....when i test it.....polymorphism effectively work on more than one level, i was told not from somebody and I trusted him without testing..... It's more likely that someone tried to tell you (and failed) that deep inheritance hierarchies are typically a sign of bad design. The conventional wisdom is to prefer composition (or aggregation, depending on you needs) over inheritance.   