I declared a class and then an object, but when I want to use my object, it gives me an error. I searched a bit on Google, but didn't understand what my problem is. The way I declared my class / object is the same as I usually do, and this is the first time it doesn't work.
Here's my .cpp
:
#include <iostream>
#include "game.h++"
int game_loop(void)
{
char *nam;
Hero *myHero = new Hero();
printf("So what's your name ? : ");
scanf("%s", &nam);
myHero->name(nam); //the error is here
}
and my .h++
:
#include <string>
class Hero
{
public:
std::string name;
int race;
int classe;
int level = 0;
int hp = 10;
int mana = 5;
};