inheritance - calling parent constructor with more parameters than the child's one in c++ -


class parent{ public: parent(string a, int i, int j, int k): name(a), num1(i), num2(j), num3(k){} ~parent(){} ... //other member functions ... protected: string a; int num1, num2, num3; };  class child : public parent{ public: child(string a, int i, int j): parent(???){}  //how should initialise base class? ~child(){} .... //other member funcitions .... } 

in above classes, parent got more data members child, many of member functions inherited parent. don't know whether there way call parent constructor have more parameters child constructor.

the child can provide whatever values needs additional parameters, eg:

class child : public parent { public:     child(string a, int i, int j): parent(a, i, j, 12345){}     ... }; 

Comments

Popular posts from this blog

javascript - Hide toolbar of pdf file opened inside iframe using firefox -

Copy range with conditional formatting -

Ansible - ERROR! the field 'hosts' is required but was not set -