C 和 C++的 不同
转自: http://studytipsandtricks.blogspot.com/2012/05/15-most-important-differences-between-c.html
Basic Introduce:
- C++ is derived from C Language. It is a Superset of C.
- Earlier C++ was known as C with classes.
- In C++, the major change was the addition of classes and a mechanism for inheriting class objects into other classes.
- Most C Programs can be compiled in C++ compiler.
- C++ expressions are the same as C expressions.
- All C operators are valid in C++.
Following are the differences Between C and C++ :
| C | C++ |
| 1. C is Procedural Language. | 1. C++ is non Procedural i.e Object oriented Language. |
| 2. No virtual Functions are present in C | 2. The concept of virtual Functions are used in C++. |
| 3. In C, Polymorphism is not possible. | 3. The concept of polymorphism is used in C++. Polymorphism is the most Important Feature of OOPS. |
| 4. Operator overloading is not possible in C. | 4. Operator overloading is one of the greatest Feature of C++. |
| 5. Top down approach is used in Program Design. | 5. Bottom up approach adopted in Program Design. |
| 6. No namespace Feature is present in C Language. | 6. Namespace Feature is present in C++ for avoiding Name collision. |
| 7. Multiple Declaration of global variables are allowed. | 7. Multiple Declaration of global varioables are not allowed. |
8. In C
|
8. In C++
|
| 9. Mapping between Data and Function is difficult and complicated. | 9. Mapping between Data and Function can be used using "Objects" |
| 10. In C, we can call main() Function through other Functions | 10. In C++, we cannot call main() Function through other functions. |
| 11. C requires all the variables to be defined at the starting of a scope. | 11. C++ allows the declaration of variable anywhere in the scope i.e at time of its First use. |
| 12. No inheritance is possible in C. | 12. Inheritance is possible in C++ |
| 13. In C, malloc() and calloc() Functions are used for Memory Allocation and free() function for memory Deallocating. | 13.In C++, new and delete operators are used for Memory Allocating and Deallocating. |
| 14. It supports built-in and primitive data types. | 14. It support both built-in and user define data types. |
| 15. In C, Exception Handling is not present. | 15. In C++, Exception Handling is done with Try and Catch block. |
随机推荐
- 树形dp入门练习(hdu1011+hdu1061)
hdu1011 和 hdu1561类似,给定每个节点的花费以及价值,并且子节点必须在父亲节点取到以后才可以被取到 相当于是在树上进行的01背包 dp时考虑每一个子树 root和它的每一个儿子,状态转移 ...
- AES - Rijndael 算法(三)
四.Rijndael算法实现,java版本 public class Rijndael_Algorithms { private byte[] key; /**------------------ ...
- 浅谈zygote服务中的设计思路
zygote服务是Android启动和服务APK的核心服务,每个APK都是通过zygote启动,今日阅读它的源码学习到一个不错的设计思路. 首先看看一个APK通过zygote的启动流程: 按照一般的设 ...
- 查看db2表空间使用率
select char(TABLESPACE_NAME,16) tablespace_name,decimal(PAGE_SIZE/1024,4,2) page,used_pages*100/usab ...
- JAVA的四种引用,强弱软虚用到的场景
1.强引用 最常用的引用类型,如Object object = new Object(),只要强引用存在,GC必定 不回收,即使当前内存空间不足,jAVA虚拟机宁愿抛出OutofMemoryError ...
- MyBatis第一个项目示例
1.创建一个Java project,JikeBook 2.添加项目所需的依赖包 如 mybatis-3.2.8.jar,是实现mybatis功能所必需的依赖包 mysql-connector-jav ...
- tcp/ip连接
1.TCP先连接(三次握手) client -> server : SYN a server -> client :SYN b, ack a+1 client -> server a ...
- 几款命令行工具(CMD)增强软件
如果经常要与 命令行工具(CMD)打交道,推荐几款工具来增强与替代 Windows 默认的 CMD. 1.PowerCMD 优点:老牌软件,功能强大,支持自定义配色方案,目前最新版本为 2.2: 缺点 ...
- linux程序自启动和新建linux服务的方法
1 linux创建自启动程序 自启动的两种方法,都经过自己测试.1.1 自启动程序方法1: 在etc/rc.local在里面加入/home/robin/code/autoruntest & ...
- Multi-touch.
TP(Multi-touch). 1.Win7有6个版本,分别如下. Windows 7 Starter (初级版) 不支 ...