Java与C++在语言方面上的不同

1,Java抛弃了头文件、预处理机制、goto语句和多维数组。

2,Java不支持指针。

3,Java抛弃了联合体和结构体。

4,Java不支持独立函数。所有函数必须在类中声明。

5,Java不支持多重继承,可以使用接口模拟多重继承。

6,Java不支持运算符重载。

7,Java中布尔型不再用整数来代替。

8,Java中主函数必须有一个字符串类型的参数。

Java抛弃的C++中的这些机制和结构多数都是“危险”的,减少了语言的复杂性,增强了安全性,虽然在一定程度上减少了其灵活性。

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *