What am I doing wrong with my separate header file?
I'm using VS, so all the linking is automatic.
This is what I'm having trouble with. It is because of the
string name;
code there, but I can't figure out what is wrong with it.
(fighter.h)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#ifndef fighter_h
#define fighter_h
//I tried added '#include <string>' but nothing happened... Same exact errors
class fighter
{
public:
string name;
int stamina;
bool alive;
bool mark;
bool turn;
fighter();
}player, player_2;
#endif
|
These are the errors.
1 2
|
missing ';' before identifier 'name'
missing type specifier - int assumed. Note: C++ does not support default-int
|
This is fighter.cpp
1 2 3 4 5 6 7 8 9
|
#include "fighter.h"
fighter::fighter()
{
stamina=0;
alive=true;
mark=false;
turn=false;
}
|
You need to #include <string>
like you said.
Also, string is in the std namespace, so you have to say:
std::string name;
Topic archived. No new replies allowed.