首先一个不同就是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.
网友评论