Home » Difference Between C and C++

Difference Between C and C++

The major difference between C and C++ is that C is a procedural programming language and does not support classes and objects, while C++ object oriented programming language and support the concept of classes and object.

The  differences between C and C++ are shown as below:

Comparison Characteristics C Language C++ Language
Approach
It follows Top Down approach. It follows Bottom Up approach.
Developed by C was developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs. C++ was developed by Bjarne Stroustrup in 1980 with C++’s predecessor “C with Classes”.
Programming type It is a Procedural Oriented language. It is an Object-Oriented Programming language
File Extension In C language, file can be saved by .c extension. In C++ language, file can be saved by .cpp extension.
Program Structure (or) Division
In C language, program is divided into small parts called functions. In C++ language, program is divided into parts called objects.
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.
Compatibility With Functions C does not support functions with default arrangements. C++ supports functions with default arrangements.
Inline function It does not allow inline function. It supports inline function.
Data Security In C language, the data is not secured. Data is secure, so it can’t be accessed by external functions. (Using Encapsulation concept of OOPs)
Namespace Feature C does not have namespace feature. C++ uses NAMESPACE which avoid name collisions.
Input/Output Function C uses functions for input/output.
For example: scanf() and printf().
C++ uses objects for input output.
For example: cin() and cout().
Virtual/friend Function C has no support for virtual and friend functions. C++ supports virtual and friend functions.
Memory Allocation/De-allocation C provides malloc() and calloc() functions for dynamic memory allocation, and free() for memory de-allocation. C++ provides new operator for memory allocation and delete operator for memory de-allocation.
Exception Handling C does not provide direct support for error handling (also called exception handling). C++ provides support for exception handling. Exceptions are used for “hard” errors that make the code incorrect.
Overloading Feature C does not support function and operator overloading. C++ supports both function and operator overloading.
Level of Language It is Mid-level language. It is High-level language.
Pointers and References C supports only Pointers. C++ supports both pointers and references.
Mapping Mapping between function and data is complicated in C. Mapping between function and data can be done easily using ‘Objects’.

Leave a comment

Your email address will not be published. Required fields are marked *