|
发表于 2004-4-12 15:23:08
|
显示全部楼层
最初由 朱镇东 发表
哎,还是不行:
程序(清华大学钱能的《c++程序设计教程》上的第一个最简单的例子):
----------------------------------
#include <iostream>
void main()
{
cout << "I am a student.\n";
}
------------------------------------------
编译结果:
-----------------------------
p7.cpp:3: `main' must return `int'
p7.cpp: In function `int main(...)':
p7.cpp:4: `cout' undeclared (first use this function)
p7.cpp:4: (Each undeclared identifier is reported only once for each function it appears in.)
钱能的书我也看过,大都用的旧标准,但是gcc对旧标准是兼容的,应该可以通过。
你的程序没有引用标准名字空间,需要在include行下加一行“using namespace std;”
或者在“cout”前加“std::” |
|