CPP01
1.0
読み取り中…
検索中…
一致する文字列を見つけられません
main.cpp
[詳解]
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* main.cpp :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2025/04/15 19:44:42 by kamitsui #+# #+# */
9
/* Updated: 2025/04/23 01:28:33 by kamitsui ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
18
#include "
HumanA.hpp
"
19
#include "
HumanB.hpp
"
20
#include "
Weapon.hpp
"
21
#include <
iostream
>
22
31
int
main
() {
32
{
33
Weapon
club =
Weapon
(
"crude spiked club"
);
34
HumanA
bob(
"Bob"
, club);
35
bob.
attack
();
36
club.
setType
(
"some other type of club"
);
37
bob.
attack
();
38
}
39
{
40
Weapon
club =
Weapon
(
"crude spiked club"
);
41
HumanB
jim(
"Jim"
);
42
jim.
setWeapon
(club);
43
jim.
attack
();
44
club.
setType
(
"some other type of club"
);
45
jim.
attack
();
46
}
47
return
0;
48
}
HumanA.hpp
Declares the HumanA class.
HumanB.hpp
Declares the HumanB class.
Weapon.hpp
Declares the Weapon class.
iostream
HumanA
Represents a HumanA, who always has a weapon.
Definition
HumanA.hpp:26
HumanA::attack
void attack() const
Makes the HumanA attack.
Definition
HumanA.cpp:43
HumanB
Represents a HumanB, who may or may not have a weapon.
Definition
HumanB.hpp:27
HumanB::setWeapon
void setWeapon(Weapon &weapon)
Sets the weapon for the HumanB.
Definition
HumanB.cpp:42
HumanB::attack
void attack() const
Makes the HumanB attack.
Definition
HumanB.cpp:53
Weapon
Represents a Weapon with a specific type.
Definition
Weapon.hpp:26
Weapon::setType
void setType(const std::string &newType)
Sets the type of the weapon.
Definition
Weapon.cpp:47
main
int main()
Main function of the program.
Definition
main.cpp:44
ex03
main.cpp
構築:
1.9.8