注册 登录
编程论坛 C++教室

“cout”: 未声明的标识符问题

自憩缘涧 发布于 2013-04-02 13:13, 8903 次点击
小弟刚开始学,代码如下:
程序代码:
#include <iostream>
#include "stdafx.h"
using namespace std;

int main ()
{
cout <<"hello world" ;
return 0;
}得到的结果如下:
1>------ 已启动生成: 项目: ex3, 配置: Debug Win32 ------
1>  源.cpp
1>e:\ex3\ex3\源.cpp(1): warning C4627: “#include <iostream>”: 在查找预编译头使用时跳过
1>          将指令添加到“stdafx.h”或重新生成预编译头
1>e:\ex3\ex3\源.cpp(7): error C2065: “cout”: 未声明的标识符
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========


请问一下,这个是什么原因啊,cout 不是在namespace 里已经声明过了吗?
6 回复
#2
马可2013-04-02 13:32
#include "stdafx.h"
在这里无法识别
#3
peach54602013-04-02 13:34
预编译头要写在第一行

看到没?
“#include <iostream>”: 在查找预编译头使用时跳过
#4
郁闷的终结2013-04-02 14:06
你的编译器是win-T?
#5
邓士林2013-04-02 22:37
你的编译器有问题吧!在我的vc6可以正常呢
#6
逆水寒刘2013-04-04 23:00
//#include "stdafx.h"不能识别该头文件,注释掉就行了,我用的是VC++6.0
#include <iostream>
using namespace std;

int main ()
{
cout <<"hello world" ;
return 0;
}
#7
haiduo2019-08-23 10:18
回复 3楼 peach5460
谢谢,给力!
1