C/C++ 不同

首先一个不同就是C是不支持对象和class类的。 C 的结构体是struct。 C++扩充了C结构体的概念, 使得他不再仅仅是一个包含不同数据的结构了。 C++的类可以包含成员函数,实现继承,多态,重载。。。
(默认访问权限class是private, struct是public。 但是可以在继承的时候指明继承方式 如 class A : public B)

C++是面向对象, C是面向过程
C语言定义所有局部变量都必须定义在函数开头。 C++可以定义在任何地方
C++是用外部的全局变量必须要用extern先声明
C++在数据类型转换的时更严格
C++增加了泛型template 增加了异常处理,增加了运算符重载,增加了命名空间

What is the difference between C and C++?
he major difference between C and C++ is that C is a procedural programming language and does not support classes and objects, while C++ is a combination of both procedural and object oriented programming language; therefore C++ can be called a hybrid language. The following table presents differences between C and C++ in detail.


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容