C 和 C++的 不同

时间:2022-09-09 11:12:11

转自: 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
  • scanf() Function used for Input.
  • printf() Function used for output.
8. In C++
  • Cin>> Function used for Input.
  • Cout<< Function used for output.
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.

随机推荐

  1. 充电时间 Go中的数组、切片、map简单示例

    数组是固定长度的,依稀让我想起了VB:切片是动态的:map一般是键值对 package main import ( "fmt" ) func main() { var userna ...

  2. python基础-异常处理

    一.错误和异常 程序中难免出现错误,而错误分成两种 1.1.语法错误(这种错误,根本过不了python解释器的语法检测,必须在程序执行前就改正) #语法错误示范一 if #语法错误示范二 def te ...

  3. pull刷新

    package com.example.mylist; import java.util.ArrayList; import java.util.List; import com.example.ad ...

  4. 在ASP&period;NET中支持断点续传下载大文件&lpar;ZT&rpar;

    IE的自带下载功能中没有断点续传功能,要实现断点续传功能,需要用到HTTP协议中鲜为人知的几个响应头和请求头. 一. 两个必要响应头Accept-Ranges.ETag         客户端每次提交 ...

  5. HW4&period;45

    public class Solution { public static void main(String[] args) { int count = 0; for(int i = 1; i &lt ...

  6. C&plus;&plus; STL的基本基本原理

    STL都是在内存的堆区分配的,但是其析构也是STL帮我们做好的,不用手动去delete. 1.vector 逻辑地址连续的一片内存空间,当空间不足,重新申请新的地址空间,将原有的数据复制过去,而新的地 ...

  7. linux重要目录说明

    1 home :root用户的home 目录是root,普通用户的home 目录是/home,users/(不要随便使用root权限,小白容易改错东西哒) 2 bin:常用可执行文件:/bin./us ...

  8. vim选中多行缩进(python多行缩进)与删除多行前面的空格

    最近用vim写python,有时候会在一段代码前面套一个循环的操作,这个时候将这一段代码整体向后平移四个空格,来满足vim缩进的要求,如何做到这一点呢? 1. ESC之后,ctrl+v进入多行行首选中 ...

  9. java基础知识-比较运算符

    演示比较运算符 == : 判断两个值是否相等 != : 判断两个数是否不相等(不能写成<>) > :判断左边值是否大于右边值 < :判断左边值是否小于右边值 >= : 判 ...

  10. HTML5的新结构标签

    在之前的HTML页面中,大家基本上都是用了Div+CSS的布局方式.而搜索引擎去抓取页面的内容的时候,它只能猜测你的某个Div内的内容是文章内容容器,或者是导航模块的容器,或者是作者介绍的容器等等.也 ...