vc中 string 类型的使用

来源:百度知道 编辑:UC知道 时间:2024/07/01 01:22:38
小弟初学c++,看书上直接在头文件中加入#include<string.h >就可以直接定义string类型的变量了,为什么我的不行!拿下边的简单程序来说吧:
#include<iostream.h>
#include<math.h>
#include<string.h >
using namespace std;
int main()
{
cout<<"what's your name ?\n";
string name;
cin>>name;
cout<<"the user'name is:"<<name;
return 0;
}
它就是运行不过去!出现以下4个错误:
'std' : does not exist or is not a namespace
'string' : undeclared identifier
syntax error : missing ';' before identifier 'name'
'name' : undeclared identifier
我看了在vc的库文件里有string.h
请高手指教!小弟感激不尽!

#include<iostream>
#include<string>
using namespace std;
int main()
{
cout<<"what's your name ?\n";
string name;
cin>>name;
cout<<"the user'name is:"<<name;
return 0;
}

请分辨好是新版的头文件还是老板的 老板的是iostream.h和string.h 当然不用std名字空间