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

《C++ Primer》第四版中到底是哪种版本的C++,VC++6.0呢?

多维数组 发布于 2007-04-15 09:54, 1670 次点击
我看过这样几种C++(两个hello world的程序):
#include <iostream.h>
int main() {
cout << "hello world" <<endl;
return 0;
}

#include <iostream>
int main() {
std::cout << "hello world" <<std::endl;
return 0;
}

这好像是两个不同的C++标准,在VC++6.0中都可以实现,我想问他们是哪种标准,VC++6又是哪种C++标准???
17 回复
#2
菜鸟上路2007-04-15 09:57
不同编译器标准不同
有#include <iostream>是更新的标准
#3
多维数组2007-04-15 10:11

我想问它们分别是几几年的标准
似乎VC++都兼容
#4
福尔摩斯2007-04-15 10:17
不一样的!

std::相当于using namespace std;

释放空间的作用!
#5
菜鸟上路2007-04-15 10:35
89和99
#6
多维数组2007-05-01 21:39
谢谢!!!!!!!!!!~~~~~~~~```
#7
福尔摩斯2007-05-02 13:37
#include <iostream.h>
int main() {
cout << "hello world" <<endl;
return 0;
}
这个是C89的

#include <iostream>
int main() {
std::cout << "hello world" <<std::endl;
return 0;
}
这个是C99的(但不标准)
#8
多维数组2007-05-02 20:23
为什么说不标准????
难道应该这样:
#include <iostream>
using std::cout;
using std::endl;
int main() {
cout << "hello world" << endl;
reruen 0;
}
//这不是一样的吗??
#9
aipb20072007-05-02 22:30

最新标准,c++98和c99!

#10
福尔摩斯2007-05-03 18:05
以下是引用多维数组在2007-5-2 20:23:20的发言:
为什么说不标准????
难道应该这样:
#include <iostream>
using std::cout;
using std::endl;
int main() {
cout << "hello world" << endl;
reruen 0;
}
//这不是一样的吗??

最标准(C++98)的是这样:

#include <iostream>
using namespace std;
int main() {
cout << "hello world" << endl;
reruen 0;
}

#11
多维数组2007-05-03 20:56
我觉得如果用
#include <iostream>
using namespace std;
int main() {
cout << "hello world" << endl;
reruen 0;
}
那么命名空间还要了有什么用?直接将std命名空间导入.

不知道大家认为新的C++好,还是旧的好。
89的C++我学过,挺简单的;现在在学99的,复杂了很多,也多了许多新东西,让我感受到了现代编译技术的厉害之处.
#12
aipb20072007-05-03 21:00
要适应新事物啊,既然标准更新了,我们也要更新啊!

谁叫c++不是我发明的!!!
#13
多维数组2007-05-03 21:04
我想如果我刚学好C++,
版本也更新了,那会......
#14
yuyunliuhen2007-05-03 21:27

#include <iostream.h> //这是老版本的了,vc++6.0还支持,vc++2005不支持,
int main() {
cout << "hello world" <<endl;
return 0;
}

#include <iostream> //最标准的形式
int main()
{
std::cout << "hello world" <<std::endl;
return 0;
}
标准库定义的在std的名字空间里,所以会有std::cout ;为了简单起见,我们通常很少使用std:的前缀,而写成全局的,using namespace std;将std的每个名字做成全局的,将一个名称空间的所有名称统统倒进全局名称空间里了,但这并不是一种很好的做法,c++开发大师Bjarne Stroustrup建议大家使用std:这种形式,平时就应该养成好的习惯。

#15
多维数组2007-05-03 22:17
#include <iostream>
using std::cout;
using std::endl;
int main()
{
cout << "hello world" << endl;
return 0;
}
//现在可以了吗?谢谢提醒

[此贴子已经被作者于2007-5-3 22:19:40编辑过]

#16
liuhu7672007-05-04 20:27
Vc++6.0!!!
#17
多维数组2007-05-05 09:38
我想知道, .net 和 没有 .net 的区别
#18
多维数组2007-05-06 21:55
在问一个问题
Visual C++ 6.0 到底是支持那种C++版本??
1