Compare commits
3 Commits
037daaf8e9
...
master
Author | SHA1 | Date | |
---|---|---|---|
cdd8fd1645 | |||
882131784b | |||
1341068efe |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
ex0*/obj/*.o
|
||||||
|
ex0*/ex0*
|
@ -10,6 +10,7 @@ Cat::Cat()
|
|||||||
|
|
||||||
Cat& Cat::operator=(const Cat& src)
|
Cat& Cat::operator=(const Cat& src)
|
||||||
{
|
{
|
||||||
|
*this->brain = *src.brain;
|
||||||
this->type = src.type;
|
this->type = src.type;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -22,6 +23,7 @@ Cat::~Cat()
|
|||||||
|
|
||||||
Cat::Cat(const Cat& src): Animal()
|
Cat::Cat(const Cat& src): Animal()
|
||||||
{
|
{
|
||||||
|
this->brain = new Brain();
|
||||||
*this = src;
|
*this = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ Dog::Dog()
|
|||||||
|
|
||||||
Dog& Dog::operator=(const Dog& src)
|
Dog& Dog::operator=(const Dog& src)
|
||||||
{
|
{
|
||||||
|
*this->brain = *src.brain;
|
||||||
this->type = src.type;
|
this->type = src.type;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -23,6 +24,7 @@ Dog::~Dog()
|
|||||||
|
|
||||||
Dog::Dog(const Dog& src): Animal()
|
Dog::Dog(const Dog& src): Animal()
|
||||||
{
|
{
|
||||||
|
this->brain = new Brain();
|
||||||
*this = src;
|
*this = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,3 +22,8 @@ WrongCat::WrongCat(const WrongCat& src): WrongAnimal()
|
|||||||
{
|
{
|
||||||
*this = src;
|
*this = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WrongCat::makeSound() const
|
||||||
|
{
|
||||||
|
std::cout << "Meow Meow !" << std::endl;
|
||||||
|
}
|
||||||
|
@ -11,4 +11,6 @@ class WrongCat : public WrongAnimal
|
|||||||
WrongCat &operator=(const WrongCat& src);
|
WrongCat &operator=(const WrongCat& src);
|
||||||
WrongCat();
|
WrongCat();
|
||||||
~WrongCat();
|
~WrongCat();
|
||||||
|
|
||||||
|
void makeSound() const;
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "Cat.hpp"
|
#include "Cat.hpp"
|
||||||
#include "Dog.hpp"
|
#include "Dog.hpp"
|
||||||
|
#include "WrongAnimal.hpp"
|
||||||
#include "WrongCat.hpp"
|
#include "WrongCat.hpp"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -12,5 +13,12 @@ int main()
|
|||||||
delete j;
|
delete j;
|
||||||
const Animal* i = new Cat();
|
const Animal* i = new Cat();
|
||||||
delete i;
|
delete i;
|
||||||
|
const WrongAnimal* k = new WrongCat();
|
||||||
|
k->makeSound();
|
||||||
|
Dog test;
|
||||||
|
{
|
||||||
|
Dog test2 = test;
|
||||||
|
}
|
||||||
|
delete k;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,6 @@ AAnimal::~AAnimal()
|
|||||||
std::cout << "~AAnimal()" << std::endl;
|
std::cout << "~AAnimal()" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AAnimal::makeSound() const
|
|
||||||
{
|
|
||||||
std::cout << "OuGAABounga" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string AAnimal::getType() const
|
std::string AAnimal::getType() const
|
||||||
{
|
{
|
||||||
return this->type;
|
return this->type;
|
||||||
|
@ -12,7 +12,7 @@ class AAnimal
|
|||||||
|
|
||||||
std::string getType() const;
|
std::string getType() const;
|
||||||
|
|
||||||
virtual void makeSound() const;
|
virtual void makeSound() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string type;
|
std::string type;
|
||||||
|
@ -10,6 +10,7 @@ Cat::Cat()
|
|||||||
|
|
||||||
Cat& Cat::operator=(const Cat& src)
|
Cat& Cat::operator=(const Cat& src)
|
||||||
{
|
{
|
||||||
|
*this->brain = *src.brain;
|
||||||
this->type = src.type;
|
this->type = src.type;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -22,6 +23,7 @@ Cat::~Cat()
|
|||||||
|
|
||||||
Cat::Cat(const Cat& src): AAnimal()
|
Cat::Cat(const Cat& src): AAnimal()
|
||||||
{
|
{
|
||||||
|
this->brain = new Brain();
|
||||||
*this = src;
|
*this = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ Dog::Dog()
|
|||||||
|
|
||||||
Dog& Dog::operator=(const Dog& src)
|
Dog& Dog::operator=(const Dog& src)
|
||||||
{
|
{
|
||||||
|
*this->brain = *src.brain;
|
||||||
this->type = src.type;
|
this->type = src.type;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -23,6 +24,7 @@ Dog::~Dog()
|
|||||||
|
|
||||||
Dog::Dog(const Dog& src): AAnimal()
|
Dog::Dog(const Dog& src): AAnimal()
|
||||||
{
|
{
|
||||||
|
this->brain = new Brain();
|
||||||
*this = src;
|
*this = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,3 +22,8 @@ WrongCat::WrongCat(const WrongCat& src): WrongAnimal()
|
|||||||
{
|
{
|
||||||
*this = src;
|
*this = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WrongCat::makeSound() const
|
||||||
|
{
|
||||||
|
std::cout << "Meow Meow !" << std::endl;
|
||||||
|
}
|
||||||
|
@ -11,4 +11,6 @@ class WrongCat : public WrongAnimal
|
|||||||
WrongCat &operator=(const WrongCat& src);
|
WrongCat &operator=(const WrongCat& src);
|
||||||
WrongCat();
|
WrongCat();
|
||||||
~WrongCat();
|
~WrongCat();
|
||||||
|
|
||||||
|
void makeSound() const;
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,10 @@ int main()
|
|||||||
delete j;
|
delete j;
|
||||||
const AAnimal* i = new Cat();
|
const AAnimal* i = new Cat();
|
||||||
delete i;
|
delete i;
|
||||||
|
Dog test;
|
||||||
|
{
|
||||||
|
Dog test2 = test;
|
||||||
|
}
|
||||||
//const AAnimal* meta = new AAnimal();
|
//const AAnimal* meta = new AAnimal();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user