Your compile error is not related to multilevel inheritance.
std::string newInf(){
return std::cout << "Boy2 name is: " << name << std::endl;
}
This is wrong. std::cout << "Boy2 name is: " << name << std::endl
is, well... a kind of std::basic_ostream &
and you cannot convert it into std::string
.
This should be OK, just like you wrote getRed()
.
void newInf(){
std::cout << "Boy2 name is: " << name << std::endl;
}