A
al
class Base
{
public:
//Base() {}
Base(int m) {}
};
class Derive : public Base
{
public:
Derive(int m) {}
};
The above code keeps giving compiler error: 'Base': no appropriate default
constructor available, until a default cstor, Base() is added into Base
class.
Does this mean that a default cstor has always to be added whenever a
non-default cstor present?
Or is this default cstor, Base(), only required during inheritance? How to
make Derive to call Base(int m) rather than Base()?
In general, when does a default cstor have to be provided?
Thanks!
{
public:
//Base() {}
Base(int m) {}
};
class Derive : public Base
{
public:
Derive(int m) {}
};
The above code keeps giving compiler error: 'Base': no appropriate default
constructor available, until a default cstor, Base() is added into Base
class.
Does this mean that a default cstor has always to be added whenever a
non-default cstor present?
Or is this default cstor, Base(), only required during inheritance? How to
make Derive to call Base(int m) rather than Base()?
In general, when does a default cstor have to be provided?
Thanks!