ex00: it works!
This commit is contained in:
commit
6d4b5788d7
16 changed files with 318 additions and 0 deletions
55
ex00/main.cpp
Normal file
55
ex00/main.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#include "Animal.hpp"
|
||||
#include "Cat.hpp"
|
||||
#include "Dog.hpp"
|
||||
#include "WrongAnimal.hpp"
|
||||
#include "WrongCat.hpp"
|
||||
#include "WrongDog.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
{
|
||||
Animal animal1 = Animal();
|
||||
Animal animal2 = animal1;
|
||||
Animal animal3;
|
||||
animal3 = animal1;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
{
|
||||
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();
|
||||
j->makeSound();
|
||||
meta->makeSound();
|
||||
|
||||
delete meta;
|
||||
delete j;
|
||||
delete i;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
{
|
||||
const WrongAnimal *meta = new WrongAnimal();
|
||||
const WrongAnimal *j = new WrongDog();
|
||||
const WrongAnimal *i = new WrongCat();
|
||||
|
||||
std::cout << j->getType() << " " << std::endl;
|
||||
std::cout << i->getType() << " " << std::endl;
|
||||
i->makeSound();
|
||||
j->makeSound();
|
||||
meta->makeSound();
|
||||
|
||||
delete meta;
|
||||
delete j;
|
||||
delete i;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
{
|
||||
const Dog *dog = new Dog();
|
||||
dog->makeSound();
|
||||
delete dog;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue