SFML community forums
Help => General => Topic started by: BMCha on May 10, 2009, 05:25:56 am
-
I have a class that inherits from sf::Sprite called AnimSprite.
Now, I'm trying to make a player class that inherits from AnimSprite.
Everything works fine until I try to add a constructor to PlayerClass. Right now the constructor is exactly the same as the (working) AnimSprite constructor.
PlayerClass::PlayerClass(std::string ImagePath) {
if (!MyImage.LoadFromFile(ImagePath)) throw(-1);
SetImage(MyImage);
}
This is the Error
In constructor `PlayerClass::PlayerClass(std::string)':
error: no matching function for call to `AnimSprite::AnimSprite()'
note: candidates are: AnimSprite::AnimSprite(const AnimSprite&)
note: AnimSprite::AnimSprite(std::string)
|=== Build finished: 1 errors, 0 warnings ===|
-
it probably means you do not have a default constructor. You need to call your AnimSprite constructor that takes an argument with an initialization list (use the : ).
Check out: http://www.cprogramming.com/tutorial/initialization-lists-c++.html