使用VC7.1不能编译如下在VC6中通过的简单代码,请指教!

格兰特杨 2004-01-15 09:42:02
#include "stdafx.h"
#include "iostream"

int _tmain(int argc, _TCHAR* argv[])
{
cout << "Hello, world!" << endl;
return 0;
}

l:\VC7Test01\VC7Test01.cpp(9): error C2065: 'cout' : undeclared identifier
l:\VC7Test01\VC7Test01.cpp(9): error C2065: 'endl' : undeclared identifier

我吐血...
...全文
60 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
格兰特杨 2004-01-15
  • 打赏
  • 举报
回复
我在vc6里用的是iostream.h,不需要std。在vc7.1中没有iostream.h了,多谢各位
yjh1982 2004-01-15
  • 打赏
  • 举报
回复
没有std,vc6也不能通过
Mephisto_76 2004-01-15
  • 打赏
  • 举报
回复
用 std:cout 代替cout。
oo 2004-01-15
  • 打赏
  • 举报
回复
没用过vc7,是不是要加上:
using namespace std;
victor_cui 2004-01-15
  • 打赏
  • 举报
回复
mark
victor_cui 2004-01-15
  • 打赏
  • 举报
回复
include "stdafx.h"
#include "iostream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Hello, world!" << endl;
return 0;
}

或者
include "stdafx.h"
#include "iostream"
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "Hello, world!" << std::endl;
return 0;
}

是名字空间的问题

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧