D
desktop
I am reading a text that says:
"The derived-class constructor initializer names its base-class followed
by a (possibly empty) list of arguments. These arguments are the initial
values to use in constructing the base-class part; the serve to select
the base-class constructor to run in order to initialize the base".
I have then made this example:
#include <string>
class BigBob {
public:
BigBob (std::string str) {
n = str;
}
std::string getName() {
return n;
}
private:
std::string n;
};
class SmallBob: public BigBob {
public:
SmallBob() { BigBob}; //naming base class followed by no
//args
private:
};
I have followed the instructions to name the base-class in the
derived-class constructor initializer followed by no arguments. But it
gives a lot of errors. What am I misunderstanding in the guide?
"The derived-class constructor initializer names its base-class followed
by a (possibly empty) list of arguments. These arguments are the initial
values to use in constructing the base-class part; the serve to select
the base-class constructor to run in order to initialize the base".
I have then made this example:
#include <string>
class BigBob {
public:
BigBob (std::string str) {
n = str;
}
std::string getName() {
return n;
}
private:
std::string n;
};
class SmallBob: public BigBob {
public:
SmallBob() { BigBob}; //naming base class followed by no
//args
private:
};
I have followed the instructions to name the base-class in the
derived-class constructor initializer followed by no arguments. But it
gives a lot of errors. What am I misunderstanding in the guide?