no default constructor exists for class x (inheritance) C++

When you declare a non-default constructor for a class, the compiler does not generate a default one anymore. So you have to provide your own.

PlayerStates needs to call a default constructor of its base class Player in its own default constructor. So you either need to provide Player with a default constructor, or call it’s non-default constructor from PlayerStates‘ default constructor initialization list.

This implicitly calls Player::Player().

PlayerStates::PlayerStates() : textureAmount( 3 ) {}

This calls the single argument constructor:

PlayerStates::PlayerStates() : Player(someComPtr), textureAmount( 3 ) {}

Leave a Comment