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. |
随机推荐
- sendmsg: no buffer space available
今天在将项目从虚拟机上移植到真实机器上面的时候,发现问题,总是不成功,最后判断是userspace的程序没有向kernel发送消息成功,因为无法触发kernel的行为,但是userspace显示正常. ...
- HDOJ(HDU) 1563 Find your present!(异或)
Problem Description In the new year party, everybody will get a "special present".Now it's ...
- Misha and Changing Handles
Description Misha hacked the Codeforces site. Then he decided to let all the users change their hand ...
- SqlServer 挂载本地盘符到服务器端,方面备份还原
--此脚本要在登录上SqlServer远程服务器后才能执行,把数据库备份到本地(内网使用) --(例如我用本机SqlServer客户端连接上192.168.3.12服务器时,执行脚本,可以把指定数据库 ...
- 採集和输出 DeckLink Studio 4K
- C++中虚函数的作用是什么?它应该怎么用呢?(转)
虚函数联系到多态,多态联系到继承.所以本文中都是在继承层次上做文章.没了继承,什么都没得谈. 下面是对C++的虚函数这玩意儿的理解. 一, 什么是虚函数(如果不知道虚函数为何物,但有急切的想知道,那你 ...
- python:字符串取值
某个字符串为stmp="abcdef54321" 取前面5个stmp[:5] #abcde 取后面5个stmp[-5:] #54321 从前面开始取,不包括最后两个stmp[:-2 ...
- oracle之时间转换
:取得当前日期是本月的第几周 SQL> select to_char(sysdate,'YYYYMMDD W HH24:MI:SS') from dual; TO_CHAR(SYSDATE,'Y ...
- mysql 的密码重置
Windows: 1.以系统管理员登陆: 2.停止MySQL服务: 3.进入CMD,进入MySQL的安装目录,假设是D:/MySQL/MySQL Server 5.0/: 4.跳过权限检查启动MySQ ...
- C# 还原SQL数据库(非存储过程方式)
Winform的代码,最好是在数据所在电脑上运行代码,不然会因为权限问题导致失败. 数据库备份: SqlConnection con = new SqlConnection("Data So ...