Difference Between C and C++

In this blog post, you will learn the difference between C and C++ programming languages. C and C++ are widely used oldest programming languages and are mainly used in embedded system applications.

This article will not only explain the difference between C and C++ but also cover some other topics. Let’s see some topics which you will learn in this article:

1. What are C and C++ languages ( C vs C++ )?

2. Difference between C and C++ programming languages?

2. Best resources to learn C languages?

3. Best resources to learn C++ languages?

4. Which language would be best to start with for a beginner?

 

What is C Programming Language?

C is a general-purpose, imperative computer programming language. It was originally developed by Dennis Ritchie between 1969 and 1973 at Bell Labs. C is standardized by the American National Standards Institute (ANSI) and subsequently by the International Organization for Standardization (ISO).

C was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support. It is the reason people called it machine-independent language.

Despite its low-level capabilities, the language was designed to encourage cross-platform programming. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers.

 

What is C++ Programming Language?

C++  is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or “C with Classes”.

It has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.

C++ introduces object-oriented programming (OOP) features to C. It offers classes, which provide the four features commonly present in OOP (and some non-OOP) languages:

One distinguishing feature of C++ classes compared to classes in other programming languages is support for deterministic destructors, which in turn provide support for the RAII ( Resource Acquisition is Initialization) concept.

 

Differences Between C and C++ ( C vs C++ ):

The below comparison chart explain some important difference between C and C++.

C Language C++ Language
C is a structural or procedural programming language. C++ is an object-oriented programming language.
 C doesn’t have variable references. C++ has variable references.
C doesn’t support function or operator overloading C++ supports function as well as function overloading.
C does not support information hiding. Data is hidden by Encapsulation to ensure that data structures and operators are used as intended.
“namespace” features are not present in C. “namespace” is used by C++, which avoids name collisions.
Virtual and friend functions are not supported by C. Virtual and friend functions are supported by C++.
In C, functions can not be defined inside structures. In C++, we can define functions inside structures.
C doesn’t provide direct support for error handling C++ supports exception handling that helps in error detection and smooth handling.
C uses malloc(), calloc() for memory allocation and  free() for memory de-allocation . In C++, generally, “new operator” is used for memory allocation, and deletes operator is used for memory deallocation.
C does not support inheritance. C++ supports inheritance.
C does not support generic programming. C++ supports generic programming with the help of templates.

 

Recommended Articles for you: