Difference Between C and C++

C is a procedural programming language that does not support classes and objects which are building blocks of object oriented programming but C++ on the other hand is the combination of procedural and object-oriented programming language. Following points will give you point by point differences between both the languages.

Difference Between C and C++

CC++
Developed in 1969 at AT&T Bell Labs by Dennis Ritchie.Developed in 1979 by Bjarne Stroustrup.
It is a subset of the C++ language.It is a superset of C. You can run most of the C code in C++ but the reverse is not possible.
Procedural programming is supported in C.Procedural and Object-oriented programming is supported.
It is a function driven language.It is an object driven language.
Data and functions are separate and free entities.Data and functions are encapsulated in the form of an object. The class is a blueprint of the object.
Does not support information hiding.Encapsulation hides the data which can be used for information hiding.
Multiple Declaration of global variables is allowed.Multiple Declaration of global variables is not allowed.
Function and Operator overloading are not supported.Function and Operator overloading are supported.
Functions can not be defined inside structures.Functions can be defined inside a structure.
Namespace the feature is not provided.Namespace is allowed to avoid name collisions.
scanf is used for input where printf is used for output.cin is used for input and cout is used for output.
Reference variables are not supported.Reference variables are supported.
Virtual and Friend functions are not supported.Virtual and Friend functions are supported.
malloc() and calloc() functions are used for dynamic memory allocation whereas free() the function is used for memory de-allocation.new the operator is used for memory allocation and delete the operator is used for memory de-allocation.
No support for object-oriented programming. So there is no support for polymorphism, encapsulation, and inheritance.Supports polymorphism, encapsulation, and inheritance which are part of object-oriented programming.
main() the function can be called from other Functions.We can not call main() function from other functions.
All variables must be defined at the starting of a scope.You can declare variables anywhere.
Inheritance is not possible.Inheritance is allowed.
Exception handling is not supported.Exception handling is supported.

Reference  Reference

Translate »