#include "Animal.hpp" #include "Dog.hpp" #include "Cat.hpp" #include "WrongAnimal.hpp" #include "WrongCat.hpp" #include #include int main() { { const Animal* meta = new Animal(); const Animal* j = new Dog(); const Animal* i = new Cat(); std::cout << j->getType() << " " << std::endl; std::cout << i->getType() << " " << std::endl; i->makeSound(); //will output the cat sound! j->makeSound(); meta->makeSound(); delete meta; delete j; delete i; } { std::cout << std::endl; const Cat* i = new Cat(); const Animal* j = new Cat(); std::cout << j->getType() << " " << std::endl; std::cout << i->getType() << " " << std::endl; i->makeSound(); j->makeSound(); delete j; delete i; } { std::cout << std::endl; const WrongAnimal* i = new WrongAnimal(); const WrongAnimal* j = new WrongCat(); std::cout << i->getType() << " " << std::endl; std::cout << j->getType() << " " << std::endl; i->makeSound(); j->makeSound(); delete j; delete i; } { std::cout << std::endl; const WrongCat* i = new WrongCat(); const WrongAnimal* j = new WrongCat(); std::cout << j->getType() << " " << std::endl; std::cout << i->getType() << " " << std::endl; i->makeSound(); j->makeSound(); delete j; delete i; } return 0; }