I have this code:
class Parent {
public:
Parent() {
init();
}
virtual void function() {
std::cout<<"Parent function"<<std::endl;
}
private:
virtual void init() {
function();
}
};
class Child : public Parent {
public:
virtual void function() {
std::cout<<"child function"<<std::endl;
}
};
I want call the function of Child from the init function of Parent when the instance of Child is created. In this case the output is "child function" instead of "Parent function".