// Single inheritance - warming up - C++11 variant. // Illustrates how a Base constructor is used in the Derived constructors member initializer. #include #include using namespace std; class Base{ public: int i; string s; Base(int i, string s): i{i}, s{s}{ } }; class Derived: public Base{ public: double d; Derived(double d, int i, string s): Base{i+1, s+s}, d{d}{ } }; int main(){ Base b1{1, "AP"}; Derived d1{5.0, 1, "AP"}; cout << b1.i << endl; // 1 cout << b1.s << endl << endl; // AP cout << d1.d << endl; // 5 cout << d1.i << endl; // 2 cout << d1.s << endl; // APAP }