Animal, Dog and Cat classes created and finished
This commit is contained in:
43
ex00/Cat/Cat.cpp
Normal file
43
ex00/Cat/Cat.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Cat.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/09/06 02:27:27 by aortigos #+# #+# */
|
||||
/* Updated: 2025/09/06 02:28:09 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "Cat.hpp"
|
||||
|
||||
Cat::Cat() : Animal()
|
||||
{
|
||||
std::cout << "Cat has been created" << std::endl;
|
||||
this->type = "Cat";
|
||||
}
|
||||
|
||||
Cat::~Cat()
|
||||
{
|
||||
std::cout << "Cat has been destroyed" << std::endl;
|
||||
}
|
||||
|
||||
Cat::Cat(const Cat &other)
|
||||
{
|
||||
std::cout << "Cat copied" << std::endl;
|
||||
*this = other;
|
||||
}
|
||||
|
||||
Cat& Cat::operator=(const Cat &other)
|
||||
{
|
||||
std::cout << "Cat copy assignment called" << std::endl;
|
||||
if (this != &other)
|
||||
this->type = other.type;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
void Cat::makeSound() const
|
||||
{
|
||||
std::cout << "Meow!" << std::endl;
|
||||
}
|
||||
31
ex00/Cat/Cat.hpp
Normal file
31
ex00/Cat/Cat.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Cat.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/09/06 02:27:27 by aortigos #+# #+# */
|
||||
/* Updated: 2025/09/06 02:28:09 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CAT_HPP
|
||||
|
||||
# define CAT_HPP
|
||||
|
||||
# include <iostream>
|
||||
# include "../Animal/Animal.hpp"
|
||||
|
||||
class Cat : public Animal
|
||||
{
|
||||
public:
|
||||
Cat();
|
||||
~Cat();
|
||||
Cat(const Cat &other);
|
||||
Cat& operator=(const Cat &other);
|
||||
|
||||
void makeSound() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user