Skip to main content

Differences between C and C++

By September 9, 2010December 13th, 2017C Programming

There are several differences regarding C and C++ programming languages. The most common is that c++ is an advanced C. C is a procedural programming language and does not support classes and objects where c++ is the combination of procedural and object oriented programming language.

Following are some differences

Basis Of Distinction C C++
1 Nature Of Language C is a structural or procedural type of programming language. C++ is an object-oriented programming language and supports Polymorphism, Abstract Data Types, Encapsulation, among others.
2 Point Of Emphasis C lays emphasis on the steps or procedures that are followed to solve a problem. C++ emphasizes the objects and not the steps or procedures. It has higher abstraction level.
3 Compatibility With Overloading C does not support function overloading. C++ supports function overloading, implying that one can have name of functions with varying parameters.
4 Data Types C does not provide String or Boolean data types. It supports primitive & built-in data types. C++ provides Boolean or String data types. It supports both user-defined and built-in data types.
5 Compatibility With Exception Handling C does not support Exception Handling directly. It can be done through some other functions. C++ supports Exception Exception:Handling can be done through try & catch block.
6 Compatibility With Functions C does not support functions with default arrangements C++ supports functions with default arrangements.
7 Compatibility With Generic Programming C is not compatible C++ is compatible with generic programming
8 Pointers And References C supports only Pointers C++ supports both pointers and references.
9 Inline Function C does not have inline function. C++ has inline function.
10 Data Security In C programming language, the data is unsecured. Data is hidden in C++ and is not accessible to external functions. Hence, is more secure
11 Approach C follows the top-down approach. C++ follows the bottom-up approach.
12 Functions For Standard Input And Output scanf and printf cin and cout
13 Time Of Defining Variables In C, variable has to be defined at the beginning, in the function. Variable can be defined anywhere in the function.
14 Namespace Absent Present
15 Division Of Programs The programs in C language are divided into modules and functions. The programs are divided into classes and functions in the C++ programming language.
16 File Extension *.C *.CPP
17 Function And Operator Overloading Absent Present
18 Mapping Mapping between function and data is complicated in C. Mapping between function and data can be done easily using ‘Objects’.
19 Calling Of Functions main() function can be called through other functions. main() function cannot be called through other functions.
20 Inheritance Possible Not possible
21 Functions Used For Memory Allocation And Deallocation malloc() and calloc for Memory Allocation and free() function for Deallocation. New and delete operators are used for Memory Allocation and Deallocation in C++.
22 Influences C++, C#, Objective-C, PHP, Perl, BitC, Concurrent C, Java, JavaScript, Perl, csh, awk, D, Limbo C#, PHP, Java, D, Aikido, Ada 95
23 Influenced By B (BCPL,CPL), Assembly, ALGOL 68, C, ALGOL 68, Simula, Ada 83, ML, CLU
24 Level of Language Mid-level High-level
25 Classes C uses structures thereby, giving freedom to use internal design elements class and structures