┌──(overlord㉿Overlord)-[~/Bureau/cpp03/ex00]
└─$ cat *.cpp *.hpp
#include "ClapTrap.hpp"

//Constructeur par défaut
ClapTrap::ClapTrap() : hitPoints(10), energyPoints(10), attackDamage(0)
{
        std::cout << "Constructeur par défaut appelé\n" << std::endl;
}

//Constructeur paramétré
ClapTrap::ClapTrap(std::string name) : name(name), hitPoints(10), energyPoints(10), attackDamage(0)
{
        std::cout << "Constructeur paramétré appelé\n" << std::endl;
}

//destructeur
ClapTrap::~ClapTrap()
{
    std::cout << "Destructeur appelé\n" << std::endl;
}

void ClapTrap::attack(const std::string& target)
{
        std::cout << "ClapTrap " << this->name << " attacks " << target.name << std::endl;
        if (this->energyPoints > 0)
        {
                target->hitPoints = target->hitPoints - this->attackDamage;
                this->energyPoints = this->energyPoints - 1;
                if (target->hitPoints < 0)
                        target->hitPoints = 0;
                 std::cout << "causing" << this->attackDamage << "points of damage!" << std::endl;
        }
        std::cout << "causing 0 points of damage!" << std::endl;
}

void ClapTrap::takeDamage(unsigned int amount)
{
        this->hitPoints = this->hitPoints - amount;
        if (this->hitPoints < 0)
                this->hitPoints = 0;
}

void ClapTrap::beRepaired(unsigned int amount)
{
        if (this->energyPoints > 0)
        {
                std::cout << "ClapTrap " << this->name << " repaired himself by " << amount << "points"<< std::endl;
                this->hitPoints = this->hitPoints + amount;
                this->energyPoints = this->energyPoints - 1;
        }
        std::cout << "ClapTrap " << this->name << " repaired himself by 0 points"<< std::endl;
}















#include "ClapTrap.hpp"


// Programme principal
int main() {
    // Utilisation du constructeur par défaut
    ClapTrap vreid;
    //vreid.afficher();

    // Utilisation du constructeur paramétré
    ClapTrap wendir(wendir);
    //wendir.afficher();

    // Les destructeurs seront appelés automatiquement
    return 0;
}
#ifndef FIXED_HPP
#define FIXED_HPP

# include <iostream>
# include <string>
# include <iomanip>
# include <cmath>

class ClapTrap
{
        private:
                std::string name;
                int hitPoints;
                int energyPoints;
                int attackDamage;
        public:

                //Constructeur par défaut
                ClapTrap();
                //Constructeur paramétré
                ClapTrap(std::string name);

                void attack(const std::string& target);
                void takeDamage(unsigned int amount);
                void beRepaired(unsigned int amount);

                //destructeur
                ~ClapTrap();
};

#endif
et voici l erreur └─$ make
c++ -Wall -Werror -Wextra -std=c++98 -c ClapTrap.cpp -o obj/ClapTrap.o
ClapTrap.cpp: In member function ‘void ClapTrap::attack(const std::string&)’:
ClapTrap.cpp:23:73: error: ‘const std::string’ {aka ‘const class std::__cxx11::basic_string<char>’} has no member named ‘name’
   23 |         std::cout << "ClapTrap " << this->name << " attacks " << target.name << std::endl;
      |                                                                         ^~~~
ClapTrap.cpp:26:23: error: base operand of ‘->’ has non-pointer type ‘const std::string’ {aka ‘const std::__cxx11::basic_string<char>’}
   26 |                 target->hitPoints = target->hitPoints - this->attackDamage;
      |                       ^~
ClapTrap.cpp:26:43: error: base operand of ‘->’ has non-pointer type ‘const std::string’ {aka ‘const std::__cxx11::basic_string<char>’}
   26 |                 target->hitPoints = target->hitPoints - this->attackDamage;
      |                                           ^~
ClapTrap.cpp:28:27: error: base operand of ‘->’ has non-pointer type ‘const std::string’ {aka ‘const std::__cxx11::basic_string<char>’}
   28 |                 if (target->hitPoints < 0)
      |                           ^~
ClapTrap.cpp:29:31: error: base operand of ‘->’ has non-pointer type ‘const std::string’ {aka ‘const std::__cxx11::basic_string<char>’}
   29 |                         target->hitPoints = 0;
      |                               ^~
make: *** [Makefile:25 : obj/ClapTrap.o] Erreur 1
                                                                                                                                                                                                                                           
┌──(overlord㉿Overlord)-[~/Bureau/cpp03/ex00]
└─$