J
jalkadir
Let's say that I have this class:
class Parent{
private: char* str;
public: const char* getStr(){return str;}
};
And then I create a child class
class Child{
private: std::string str;
public: std::string& getStr(){return str;}
};
How do I call the Parent class method in a program, i.e.
int main(){
Child obj;
std::cout << obj.getStr() << std::endl;
return 0;
}
In the above example the method access would be the Child::getStr(),
but I would like to access the Parent::getStr(), how do I do that?
TIA.
class Parent{
private: char* str;
public: const char* getStr(){return str;}
};
And then I create a child class
class Child{
private: std::string str;
public: std::string& getStr(){return str;}
};
How do I call the Parent class method in a program, i.e.
int main(){
Child obj;
std::cout << obj.getStr() << std::endl;
return 0;
}
In the above example the method access would be the Child::getStr(),
but I would like to access the Parent::getStr(), how do I do that?
TIA.