d04 ex00
This commit is contained in:
52
d04/main.cpp
Normal file
52
d04/main.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user