分页: 1 / 1

使用g++时候出现错误!!!!(已解决!!)

发表于 : 2007-03-31 1:12
tomlillite
#include<iostream.h>
int main()
{
cout<<"Hello world!"<<endl;
return 0;
}
文件名为hello.cpp
使用g++ hello.cpp
之前已经安装了g++还有c++的库,可编译的时候出现错误,不明!!!!!
hello.cpp:1: error: stray ‘\357’ in program
hello.cpp:1: error: stray ‘\274’ in program
hello.cpp:1: error: stray ‘\203’ in program
hello.cpp:1: error: expected constructor, destructor, or type conversion before ‘<’ token
各位到底是怎么回事呢?????

发表于 : 2007-03-31 22:34
titainium
为啥现在还有写<iostream.h>的?
为啥现在还有不知道namespace的?

发表于 : 2007-03-31 22:41
BigSnake.NET
打程序源代码..不要复制粘贴

发表于 : 2007-04-03 10:00
antonym55
ISO C++ 中的头文件是 没有h的

代码: 全选

#include <iostream>
没有h时,需要使用cout 可以有下面2种方式
1. using namespace std;
2. 使用 std::cout

完整程序

代码: 全选

#include <iostream>
using namespace std;

int main(int argc, char**  argv)
{
    cout << " Hello World!" <<endl;
    return 0;
}
或者

代码: 全选

#include <iostream>

int main(int argc, char**  argv)
{
    std::cout << " Hello World!" <<std::endl;
    return 0;
}

发表于 : 2007-04-03 10:22
zzyubuntu
! :em06

多谢了!!!

发表于 : 2007-04-03 23:29
tomlillite
因为在windows上用久了,vc6.0就那样编写的,所以……
多谢大家了哦!!!!
:lol: