CPP01 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
HumanA.cpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* HumanA.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/04/15 19:43:03 by kamitsui #+# #+# */
9/* Updated: 2025/04/23 01:28:05 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
18#include "HumanA.hpp"
19#include <iostream>
20
29HumanA::HumanA(std::string name, Weapon &weapon) : name(name), weapon(weapon) {
30 std::cout << "HumanA '" << this->name << "' created with weapon '" << this->weapon.getType() << "'." << std::endl;
31}
32
36HumanA::~HumanA() { std::cout << "HumanA '" << this->name << "' destroyed." << std::endl; }
37
43void HumanA::attack() const {
44 std::cout << this->name << " attacks with their " << this->weapon.getType() << std::endl;
45}
Declares the HumanA class.
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
ostream cout
void attack() const
Makes the HumanA attack.
Definition HumanA.cpp:43
HumanA(std::string name, Weapon &weapon)
Constructor for the HumanA class.
Definition HumanA.cpp:29
~HumanA()
Destructor for the HumanA class.
Definition HumanA.cpp:36
Represents a Weapon with a specific type.
Definition Weapon.hpp:26
const std::string & getType() const
Gets the type of the weapon.
Definition Weapon.cpp:40