Animal finished
This commit is contained in:
@@ -22,4 +22,21 @@ Animal::~Animal()
|
|||||||
std::cout << "Animal has been destroyed" << std::endl;
|
std::cout << "Animal has been destroyed" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Animal::Animal(const Animal &other)
|
||||||
|
{
|
||||||
|
std::cout << "Animal copied" << std::endl;
|
||||||
|
*this = other;
|
||||||
|
}
|
||||||
|
|
||||||
|
Animal& Animal::operator=(const Animal &other)
|
||||||
|
{
|
||||||
|
std::cout << "Animal copy assignment called" << std::endl;
|
||||||
|
if (this != &other)
|
||||||
|
this->type = other.type;
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animal::makeSound() const
|
||||||
|
{
|
||||||
|
std::cout << "Animal weird sounds..." << std::endl;
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,7 +22,11 @@ class Animal
|
|||||||
std::string type;
|
std::string type;
|
||||||
public:
|
public:
|
||||||
Animal();
|
Animal();
|
||||||
~Animal();
|
virtual ~Animal();
|
||||||
|
Animal(const Animal &other);
|
||||||
|
Animal& operator=(const Animal &other);
|
||||||
|
|
||||||
|
virtual void makeSound() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user