CPP04 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
Cat.cpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* Cat.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/05/20 16:26:14 by kamitsui #+# #+# */
9/* Updated: 2025/06/03 23:27:28 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
21#include "Cat.hpp"
22
29 this->type = "Cat";
30 std::cout << "Cat default constructor called" << std::endl;
31}
32
39Cat::Cat(const Cat &other) : Animal(other) { std::cout << "Cat copy constructor called" << std::endl; }
40
45Cat::~Cat() { std::cout << "Cat destructor called" << std::endl; }
46
53Cat &Cat::operator=(const Cat &other) {
54 std::cout << "Cat copy assignment operator called" << std::endl;
55 if (this != &other) {
56 Animal::operator=(other);
57 }
58 return *this;
59}
60
65void Cat::makeSound() const { std::cout << "Meow!" << std::endl; }
The Animal class represents a generic animal.
Definition Animal.hpp:37
Animal & operator=(const Animal &other)
Copy assignment operator for Animal. Assigns the type from the other Animal object....
Definition Animal.cpp:47
std::string type
Definition Animal.hpp:39
The Cat class represents a feline animal.
Definition Cat.hpp:33
virtual void makeSound() const
Makes the characteristic sound of a cat ("Meow!"). This function overrides the virtual makeSound() fr...
Definition Cat.cpp:65
Cat & operator=(const Cat &other)
Copy assignment operator for Cat. (Copy And Swap Idiom) Displays a specific copy assignment message.
Definition Cat.cpp:53
virtual ~Cat()
Destructor for Cat. Displays a specific destruction message.
Definition Cat.cpp:45
Cat()
Default constructor for Cat. Calls the Animal base class constructor and sets the type to "Cat"....
Definition Cat.cpp:28
T endl(T... args)
Declares the Cat class.