How to make my header files work

Hi guys, I could do with some help regarding a problem I'm having with header files, specifically to do with the string data type. The objects work perfectly when I put them inside the .cpp but when I set it to include the exact same code in a .h, I get a string of error messages. Can someone please take a look at this snippet from the header to see where I'm going wrong?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class Topic
{
private:
string NInfo, SInfo, EInfo, WInfo, Name ;
bool Quest ;

public:
void setNInfo(string NI) { NI = NInfo ; }
void setSInfo(string SI) { SI = SInfo ; }
void setEInfo(string EI) { EI = EInfo ; }
void setWInfo(string WI) { WI = WInfo ; }
void setQuest(bool Q) { Q = Quest ; }

string getNInfo() {return NInfo ;}
string getSInfo() {return SInfo ;}
string getEInfo() {return EInfo ;}
string getWInfo() {return WInfo ;}
bool getQuest() {return Quest ;}
} ;

class Weapon
{
protected:
int DamMod, SpeedMod ;
string Attack1, Describe1, Name ;

public:
void setDamMod(int DM) {DamMod = DM ;}
void setSpeedMod(int SM) {SpeedMod = SM ;}
void setAttack1(string A1) {Attack1 = A1 ;}
void setDescribe1(string D1) {Describe1 = D1 ;}
void setName(string ID) {Name = ID ;}
int getDamMod() {return DamMod ;}
int getSpeedMod() {return SpeedMod ;}
string getAttack1() {return Attack1 ;}
string getDescribe1() {return Describe1 ;}
string getName() {return Name ;}
} ;

class Special : public Weapon
{
protected:
string Attack2, Describe2 ;
int BonusDam, Cost ;

public:
void setAttack2(string A2) {Attack2 = A2 ;}
void setDescribe2(string D2) {Describe2 = D2 ;}
void setBonusDam(int BD) {BonusDam = BD ;}
void setCost(int MC) {Cost = MC ;}
string getAttack2() {return Attack2 ;}
string getDescribe() {return Describe2 ;}
int getBonusDam() {return BonusDam ;}
int getCost() {return Cost ;}
} ;


Thanks for taking the time to view this post.
Last edited on
Sorry to even post this, I solved the problem by myself by replacing the string data type with std::string. It didn't compile before when I did that because for some reason an exe was running in the background and blocking it (I honestly don't know)
Topic archived. No new replies allowed.