I have the following class:
class Tileset { //base class
public:
static std::vector<Tileset*> list;
virtual ~Tileset() = 0;
protected:
std::vector<Tile> tiles_list;
sf::Texture sheet;
private: //non copiable
Tileset(const Tileset&);
Tileset& operator=(const Tileset&);
};
where sf::Texture
has a default constructor
From my understanding a default constructor should be generated since every member can be default-constructed too.
Yet I have a compiler error when I try to construct a derived object without calling a Tileset
constructor.
Can someone explain why no default constructor is generated?
edit : forgot to mention that Tile
class doesn't have a default constructor. I'm not sure if that changes anything
A default constructor will be not be generated if any of the following are true
const
or reference field You declared a constructor hence C++ won't provide a default generated one. In this case though all of the fields of Tileset
have useful default constructors so defining a default constructor here is very easy
Tileset() { }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With