c++ - Unable to call public method of the base class from a child's instance -


i wanted try constructor inheritance in c++ , worked fine. found can't call method instance of daughter class. visual studio says

the method mother::showname not available

even though public, far concerned must available child class. there doing wrong?

class mother{  protected:   char* name;  public :       mother(char* _name){       name = _name;   }    void showname(){       cout << "my name is: " << name << endl;   } };   class daughter : mother{ public:   daughter(char* _name) : mother(_name) {   } };  int main(){   daughter d1("masha");   d1.showname();    return 0; } 

class daughter : mother private inheritance. class inheritance default.

class daughter : public mother you're looking for.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -