如何在头文件中定义string类型

如题
//System.h=======================
string c;
//main.cpp=======================
#include"System.h"
#include<iostrem>
using namespace std;

void main ()
{ cin>>c;}

编译错误:
g:\SYSTEM.h(3) : error C2146: syntax error : missing ';' before identifier 'c'
g:\SYSTEM.h(3) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
g:\SYSTEM.h(3) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

这些是什么意思呀?
加过<string>;<string.h>还是一样不行
我用的是Microsoft Visual Studio 2005
最好举个例子来参考下

string是标准库std里的一种数据类型,在程序开始加上#include<string>即可定义;
参考实例如下:
#ifndef head_h
#define head_h
#include <string>
using namespace std;
#define Max 3
#define Charge 5
class Car_Park
{
private:
string carname ;
string carnum;
};
#endif
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-08-01
string 不明白!我用了很长时间VC了 一直在用CString 用这个好点!

参考资料:VC

第2个回答  2008-08-02
string是标准库std里的一种数据类型,所以你必须先用using namespace再定义string数据类型
#include<iostream>
#include<string>
using namespace std;
string c;
int main(){
cin>>c;

}

这样就可以了本回答被提问者采纳
第3个回答  2008-08-01
最开头加上
#include<string>
即可
相似回答