#include <iostream.h>
#include <string.h>
using namespace std;int main()
{
string strName; cout<<"Please input your name:";
cin>>strName;
cout<<"\nHello"
<<strName
<<"....GoodBye!"; return 0;
}
这是essential c++中的第一个例子程序。
我在vc6++下编译有四个错误:
D:\C++\Test1_1\Test1_1.cpp(4) : error C2871: 'std' : does not exist or is not a namespace
D:\C++\Test1_1\Test1_1.cpp(8) : error C2065: 'string' : undeclared identifier
D:\C++\Test1_1\Test1_1.cpp(8) : error C2146: syntax error : missing ';' before identifier 'strName'
D:\C++\Test1_1\Test1_1.cpp(8) : error C2065: 'strName' : undeclared identifier那位能告诉我应该怎么解决吗?
#include <string.h>
using namespace std;int main()
{
string strName; cout<<"Please input your name:";
cin>>strName;
cout<<"\nHello"
<<strName
<<"....GoodBye!"; return 0;
}
这是essential c++中的第一个例子程序。
我在vc6++下编译有四个错误:
D:\C++\Test1_1\Test1_1.cpp(4) : error C2871: 'std' : does not exist or is not a namespace
D:\C++\Test1_1\Test1_1.cpp(8) : error C2065: 'string' : undeclared identifier
D:\C++\Test1_1\Test1_1.cpp(8) : error C2146: syntax error : missing ';' before identifier 'strName'
D:\C++\Test1_1\Test1_1.cpp(8) : error C2065: 'strName' : undeclared identifier那位能告诉我应该怎么解决吗?
解决方案 »
- 其原因可能是堆被损坏,这说明.exe 中或它所加载的任何 DLL 中有 Bug。
- 连接代理总是返回403错误,怎么回事?
- 数据库读取操作不能放在 myView下面处理?
- 有没有人用过VS2008的单选框啊?好像设置为int类型之后更新不到界面上去。。
- cricheditdoc cricheditview CRichEditCntrItem 如何利用MFC新建这样一个工程呢?
- 工具栏按钮更换图标
- 在函数正确返回前报错,可能是什么原因呢?多谢指教~~
- vc++中那個文件是存儲類信息的,我的工程不知丟了那個文件導致了文件區中的類無法顯示!在線等!急
- 为什么程序启动的时候会自动调用appmodul.cpp中的_tWinMain函数,我并没有将appmodul.cpp加入我的工程中呀??
- 急问一个简单问题
- 菜鸟问题,请问vc中如何设置窗口的大小(不是对话框)?
- 什么API函数可以获得当前默认邮件处理程序?
#include <iostream>
#include <string>
而不是
#include <iostream.h>
#include <string.h>
不能用#include <iostream.h>和#include <string.h>。
要改为#include <iostream>和#include <string>。
不用using namespace std;则可用#include <iostream.h>