一个伴娘堵门的开场白:C++起步者的问题

来源:百度文库 编辑:高考问答 时间:2024/05/04 15:50:48
我是从一本C++学习书自己开始的,但是在第一个程序就出现了问题~请教下面的语句该怎么改。谢谢!
#include<iostream>

int main()
{
std::cout<<"hello world!\n";
return0;
}
这是原文里的语句

#include<iostream.h>

int main()
{
std::cout<<"hello world!\n";
return 0;
}

如果上面的这个不能编译通过,就试试这个

#include<iostream.h>

void main()
{
std::cout<<"hello world!\n";

}

什么问题啊?

没有任何问题,但是建议换一个比较新的编译器。旧的编译器可能不支持C++标准库。
VC7.1 和 BCB6都可以的,我试过了

你首先要确认你用是什么编译器!
如果用TC3.0就
#include<iostream.h>

void main()
{
cout<<"hello world!\n";
}
一定通过

如果采用VC控制台程序编写
就要改成
using namespace std
#iclude<iostream>

int main()
{
std::cout<<"hello world!\n";
return 0;
}