CPP04 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
WrongAnimal.cpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* WrongAnimal.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/05/20 16:26:48 by kamitsui #+# #+# */
9/* Updated: 2025/05/20 23:17:46 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
21#include "WrongAnimal.hpp"
22
28WrongAnimal::WrongAnimal() : type("Generic WrongAnimal") {
29 std::cout << "WrongAnimal default constructor called" << std::endl;
30}
31
38WrongAnimal::WrongAnimal(const WrongAnimal &other) : type(other.type) {
39 std::cout << "WrongAnimal copy constructor called" << std::endl;
40}
41
51 std::cout << "WrongAnimal copy assignment operator called" << std::endl;
52 if (this != &other) {
53 this->type = other.type;
54 }
55 return *this;
56}
57
64WrongAnimal::~WrongAnimal() { std::cout << "WrongAnimal destructor called" << std::endl; }
65
71void WrongAnimal::makeSound() const { std::cout << "Wrong generic animal sound" << std::endl; }
72
77const std::string &WrongAnimal::getType() const { return this->type; }
The WrongAnimal class represents a generic animal, used to demonstrate the LACK of polymorphism when ...
WrongAnimal()
Default constructor for WrongAnimal. Initializes the type to "Generic WrongAnimal"....
std::string type
WrongAnimal & operator=(const WrongAnimal &other)
Copy assignment operator for WrongAnimal. Assigns the type from the other WrongAnimal object....
const std::string & getType() const
Gets the type of the WrongAnimal.
void makeSound() const
Makes a generic sound for a WrongAnimal. This function is intentionally NOT VIRTUAL to show the lack ...
virtual ~WrongAnimal()
Destructor for WrongAnimal. Displays a destruction message. Note: Declared virtual in the header to e...
T endl(T... args)
Declares the WrongAnimal class.