String Error

Hi everyone, I'm trying to compile this simple RPG game on Dev C++ and get an error at the commented places below. The confusing thing is I've gotten the string array code from a book, and it's worked before! Any help would be greatly appreciated!
-------------------------------------------------------------------------------
#include <iostream>
#include <string>
using namespace std;

int main() {

//enemy stuff:
class enemy {
public:
string eName;
int eHP,eMAXHP,eDEF,eATK,eLUCK,eXP,eShill; } stats

//player stuff:
class weapon {
public:
string wName;
int wATK; }

class armor {
public:
string aName;
int aDEF; }

string jobs[]=("Crusader", "Hunter", "Astrologer", "Reaper"); //error here

string pNAME,pCLASS,pWEAPON; //error here
-------------------------------------------------------------------------------
It would help if you told us what error you're getting....

But at first glance it appears you're missing semicolons:

1
2
3
4
class myclass
{
  // stuff here
};   //  <-- note you need a semicolon 


For making an object right away as you seem to be doing with 'enemy', put the semicolon after the object name:

1
2
3
4
5
6
7
8
9
10
11
12
class enemy
{
  // stuff
} stats;

// alternatively... this has the same effect:

class enemy
{
};

enemy stats;
2 basic errors in your code are:

1. No semi-colon after class declaration
2. Wrong type of brackets for string array initialization

Below is the corrected code.

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
int main() {

//enemy stuff:
class enemy {
public:
string eName;
int eHP,eMAXHP,eDEF,eATK,eLUCK,eXP,eShill; };  

enemy stats;

//player stuff:
class weapon {
public:
string wName;
int wATK; };

class armor {
public:
string aName;
int aDEF; };

string jobs[]={"Crusader", "Hunter", "Astrologer", "Reaper"}; //error here

string pNAME,pCLASS,pWEAPON; //error here

return 0;
}
Awesome guys, sorry for not posting the error message. I got it to work now, thanks so much!
Topic archived. No new replies allowed.