cpp04/ex00/main.cpp
2025-07-04 13:51:34 +02:00

55 lines
1.1 KiB
C++

#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;
}