CPP04 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
AMateria.hpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* AMateria.hpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/05/29 22:44:34 by kamitsui #+# #+# */
9/* Updated: 2025/06/04 00:56:32 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
24#ifndef AMATERIA_HPP
25#define AMATERIA_HPP
26
27#include "ICharacter.hpp" // Required for the ICharacter reference in the use method
28#include <iostream> // For standard input/output operations (e.g., std::cout)
29#include <string> // For std::string to store materia type
30
42class AMateria {
43 protected:
44 std::string const type; // Type is const, set at construction
45
46 private:
47 // Default constructor made private/unavailable as type is essential
48 AMateria();
49
50 public:
52 AMateria(const AMateria &other);
53 virtual ~AMateria();
54 // Assignment operator: type is const, so it won't be changed by base class assignment.
55 // Derived classes can override if they have other members.
56 virtual AMateria &operator=(const AMateria &rhs); // rhs : "right hand side"
57
58 std::string const &getType() const; // Returns the materia type
59
60 virtual AMateria *clone() const = 0;
61 virtual void use(ICharacter &target);
62};
63
64#endif
Declares the ICharacter interface.
Represents an abstract base class for all magical materias.
Definition AMateria.hpp:42
virtual AMateria & operator=(const AMateria &rhs)
Copy assignment operator for AMateria. Assigns the type from another AMateria object....
Definition AMateria.cpp:55
virtual ~AMateria()
Destroys the AMateria object.
Definition AMateria.cpp:68
virtual AMateria * clone() const =0
std::string const & getType() const
Gets the type of the materia.
Definition AMateria.cpp:78
virtual void use(ICharacter &target)
Uses the materia on a target character. This is a virtual function with a base implementation that pr...
Definition AMateria.cpp:86
std::string const type
Definition AMateria.hpp:44
An interface for any character that can interact with Materias.