I am exploring diamond problem. I have written below code. However it shows ambiguous issue. How to resolve it? Is it possible without overriding method in Snake class?
#include <iostream>
class LivingThing {
protected:
void breathe()
{
std::cout << "I'm breathing as a living thing." << std::endl;
}
};
class Animal : virtual protected LivingThing {
protected:
void breathe() {
std::cout << "I'm breathing as a Animal." << std::endl;
}
};
class Reptile : virtual public LivingThing {
public:
void breathe() {
std::cout << "I'm breathing as a Reptile." << std::endl;
}
};
class Snake : public Animal, public Reptile {
};
int main() {
Snake snake;
snake.breathe();
getchar();
return 0;
}