I get
error: no matching function for call to 'Base::Base()'
in code
class Base {
private:
char *field;
public:
Base(char *c){
field = c;
}
};
class Derived : public Base {
public:
Derived(char *c){}
};
Error disappears as soon as I add
Base() {}
constructor. Why does the C++ compiler strictly require a Base() constructor with no arguments? What if creating a Base object with no arguments makes no sense?
P.S. For example, I do not have the same error in similar Java code because I would have to add
super("")
as a first statement of body of Derived constructor. And that is really reasonable.
Derivedclass makes no sense.