Files
42_INT_09_piscine_cpp/d04/ex01/main.cpp

53 lines
1.2 KiB
C++

#include "Animal.hpp"
#include "Dog.hpp"
#include "Cat.hpp"
#include "WrongAnimal.hpp"
#include "WrongCat.hpp"
#include <iostream>
#include <string>
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();
{
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(); //will output the cat sound!
j->makeSound();
}
{
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(); //will output the cat sound!
j->makeSound();
}
{
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(); //will output the cat sound!
j->makeSound();
}
return 0;
}