cpp04/ex01/Animal.cpp

38 lines
691 B
C++

# include "Animal.hpp"
Animal::Animal (std::string type) : _type(type)
{
std::cout << "Animal constructor called\n";
}
Animal::Animal() : _type("Default")
{
std::cout << "Animal def constructor called\n";
}
Animal::Animal(const Animal &other) : _type(other._type)
{
std::cout << "Animal copy constructor called\n";
}
Animal &Animal::operator=(const Animal &other)
{
_type = other._type;
std::cout << "Animal copy assignment constructor called\n";
return (*this);
}
Animal::~Animal()
{
std::cout << "Animal deconstructor called\n";
}
void Animal::makeSound() const
{
std::cout << "Animal can make different sounds.\n";
}
std::string Animal::getType() const
{
return (_type);
}