int main()
{
- const Animal* meta = new Animal();
- const Animal* j = new Dog();
- const Animal* i = new Cat();
+ const Animal* base = new Animal();
+ const Animal* cat = new Cat();
+ const Animal* dog = new Dog();
+ const WrongAnimal* wrong_base = new WrongAnimal();
+ const WrongAnimal* wrong_cat = new WrongCat();
- const WrongAnimal* meta2 = new WrongAnimal();
- const WrongAnimal* i2 = new WrongCat();
-
- std::cout << j->getType() << " " << std::endl;
- std::cout << i->getType() << " " << std::endl;
- i->makeSound();
- j->makeSound();
- meta->makeSound();
- std::cout << i2->getType() << " " << std::endl;
- i2->makeSound();
- meta2->makeSound();
+ std::cout << '\n' << base->getType() << ": ";
+ base->makeSound();
+ std::cout << cat->getType() << ": ";
+ cat->makeSound();
+ std::cout << dog->getType() << ": ";
+ dog->makeSound();
+ std::cout << '\n' << wrong_base->getType() << ": ";
+ wrong_base->makeSound();
+ std::cout << wrong_cat->getType() << ": ";
+ wrong_cat->makeSound();
+ std::cout << '\n';
+ delete base;
+ delete cat;
+ delete dog;
+ delete wrong_base;
+ delete wrong_cat;
return (0);
}