string and class header file

How come when i try to compile this program im writing i get string does not name a type? the program is just a simple program where someone enters a the player name with salary and stuff.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//This is the header file
#include <string>
#ifndefine SALARY_H
#define SALARY_H

class salary{
private:
  string playername = "";
  long int salary;
  long int contract;
  
public:
  
  
  
  
}
salary.h:8:3: error: ‘string’ does not name a type
#ifndefine should be #ifndef . You also need #endif at the end of the file.

There should be a semicolon at the end of line 17.

string is defined in the std namespace so it should be std::string. std::string playername = "";
You have to use: std::string
Or you could use namespace: using std::string
ok i fixed it but i still get that error does not name a type.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//this is the program salary header file.
#ifndef SALARY_H
#define SALARY_H
using namespace std;
class salary{
private:
  string playername;
  long int contract;
  long long int salary;
  
public:
  
  
};
#endif 
You still need to include <string>
ok i see thanks! you guys are awesome!
Removed the using stuff. Stick with explicit qualification (std::string) in header files to avoid polluting the global scope of other headers.
Topic archived. No new replies allowed.