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
31int 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}
Declares the HumanA class.
Declares the HumanB class.
Declares the Weapon class.
Represents a HumanA, who always has a weapon.
Definition HumanA.hpp:26
void attack() const
Makes the HumanA attack.
Definition HumanA.cpp:43
Represents a HumanB, who may or may not have a weapon.
Definition HumanB.hpp:27
void setWeapon(Weapon &weapon)
Sets the weapon for the HumanB.
Definition HumanB.cpp:42
void attack() const
Makes the HumanB attack.
Definition HumanB.cpp:53
Represents a Weapon with a specific type.
Definition Weapon.hpp:26
void setType(const std::string &newType)
Sets the type of the weapon.
Definition Weapon.cpp:47
int main()
Main function of the program.
Definition main.cpp:44