Differences between C and C++ programming languages
This tutorial is about the differences between C and C++ programming languages. As we know, C++ is an extended version of C, and hence it has many similarities with its parent language. The purpose of C++ was to bring in some changes that could help to overcome the disadvantages of C such as the concept of namespaces, run-time checking, no object-oriented properties, no exception handling, etc. Thus C++ is different than C in many ways. These differences have been discussed below.
Differences between C and C++
The differences between C and C++ programming languages have been given in the below table.
C | C++ |
---|---|
C was developed between the year 1969 and 1973 at AT&T Bell Labs by an American computer scientist Dennis Ritchie. | C++ was developed in 1979 by a Danish computer scientist Bjarne Stroustrup. |
C supports procedural programming paradigm. | C++ supports both procedural as well as the object-oriented programming paradigm. |
C is a subset of C++. | As C++ is an extension of C, it can be called a superset of C. |
C does not support polymorphism, inheritance or encapsulation as C does not support object-oriented programming. | C++ supports polymorphism, inheritance or encapsulation as it supports object-oriented programming |
C has 32 reserved keywords. | As of now, there are more than 60 keywords in C++. |
In C, data and function are separated. | In C++, data and function are kept together by encapsulation. |
C does not support reference variables. | C++ supports reference variables. |
Since C is a procedural programming language, it is function-driven. | C++ is an object driven language. |
C does not support function and operator overloading. | C++ supports function and operator overloading. |
In C, we cannot define functions inside structures. | In C++, functions can be defined and used inside structures. |
C does not have any namespace feature. | C++ provides us with a namespace feature that avoids name-collision in the program. |
C does not support virtual and friend functions. | C++ supports virtual and friend functions. |
C focuses on methods instead of data. | C++ focuses on data rather than method or process. |
C has no support for exception handling. | C++ provides ways to handle such exceptions. |
C uses malloc() or calloc() for dynamic memory alloaction free() for deallocation. | C++ uses the new operator for memory allocation and delete operator for deallocation. |
C uses functions scanf() and printf() for input and output respectively. | C++ uses cin and cout objects for input and output respectively. |
Thank you.
Leave a Reply