Difference Between C & C++

In this section of the C++ Tutorial, let’s have a look at the difference between C & C++. Both C & C++ are widely used programming language, however, the major difference between C and C++ is that C does not support classes whereas C++ support it.

Let’s have a look at the difference between C and C++ based on some classification parameters.

Difference Between C & C++

Parameters C C++
Development C was developed by Dennis Ritchie between the years 1969 and 1973 at AT&T Bell Labs. C++ was developed by Bjarne Stroustrup in 1979.
Subset/superset C is a subset of C++. C++ is a superset of C.
Approach C follows the top-down approach. C++ follows the bottom-up approach.
Data security Data is less secured in C. In C++, you can use modifiers for class members to make it inaccessible for outside users.
Focus Instead of focusing on data, C focuses on method or process. C++ focuses on data instead of focusing on method or procedure.
Programming language type C is a function-driven language because C is a procedural programming language. C++ is an object driven language because it is object-oriented programming.
Functions Functions in C are not defined inside structures. Functions can be used inside a structure in C++.
Program division C programs are divided into procedures and modules C++ programs are divided into functions and classes.
Data and functions Data and functions are separated in C because it is a procedural programming language. Data and functions are encapsulated together in the form of an object in C++.
Header files Header file used by C is stdio.h. Header file used by C++ is iostream.h.
Keywords C contains 32 keywords. C++ contains 52 keywords.
Input/Output In C, scanf() and printf() are mainly used for input/output. C++ mainly uses stream cin and cout to perform input and output operations.
Memory allocation/deallocation 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.
Expection Handling Exception handling is not easy in C. It has to perform using other functions. C++ provides exception handling using Try and Catch block.
Function Overloading Not supported Supported
Functions in structure Not supported Supported
Reference variables. Not supported Supported
Operator overloading Not supported Supported
Namespace Not supported Supported
Polymorphism, Encapsulation, and Inheritance Not supported Supported
Function and operator overloading Not supported Supported
Virtual and friend functions Not supported Supported

 

Leave a Reply

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

Shopping cart