C Vs C++

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 6

Difference between C and

C++
Difference between C and C++
Parameter C C++
The C programming language is a C++ is an object-oriented programming
Programming Style procedural language type.  The language language type. The language is object-
is function-driven. driven.

C programming follows a top to down C++ follows a bottom-to-top approach


Approach programming approach that focuses on that focuses on data rather than the
the steps rather than the data.  overall procedure. 

As C is a structured programming
language, the program is divided into As C++ is an object-oriented
Program Division blocks known as functions which can be programming language, the code
viewed as individual components of the consists of Objects and Classes.
program. 

Besides built-in data types, C++ also


C supports built-in data types. C is a basic
Data Types version of a programming language and supports user-defined data types. C++ is
an enhanced version of C and supports
supports only primitive, fixed data types.  generic data types. 
Contd…
C does not support exception C++ supports exception handling
Exception Handling handling, i.e., support in times of and provides efficient support
‘hard’ errors causing code during errors and incorrect codes. 
problems. 

C++ programming language is


This programming language is suitable and extensible for high-
Application Development more suitable for assemblers, text end programming including game
editors, network drivers, and low- development, embedded systems
level implementations.  like smartwatches, medical
machines, etc. 

C is the foundational language C++ is the superset of the C


Compatibility and, hence, the code written with language including OOP concepts
C can be run with the C++ and hence, cannot run the code in
compiler.  the C compiler. 

File Extension .c is the file extension for the C .cpp is the file extension for C++. 
programming language. 
Also known as Hands-on language C++ is a more object-oriented
which means C allows the high-level programming language
Ease Of Coding  programmer to tell everything. which requires fixed construction
Therefore, one can program it the and principles. However, it is
way we want. It is easy.  easier to code.
Contd…
C programming language does not
adhere to the encapsulation C++ is a more secure programming
Data Security
concept and allows easy data language. 
manipulation from outside code. 
Inline Function C does not support inline function. C++ supports inline functions. 
A variable is like a storage location Variables in C++ can be declared
Variable and in C it needs to be defined at anytime. 
the beginning itself. 
To organize the code for efficiency
Namespace and prevent collisions, namespace C++ as a flexible programming
is required. C does not support language supports namespace. 
that. 
Contd…

C was the base of many


foundational languages and is itself C++ was developed, and inspired
Source code
known for its free format source by the C programming language. 
code. 
Microsoft Windows Kernel, Google Chrome, Microsoft Office,
Used By Telegram Messenger, Oracle Torque 3-D game engine, and so
Database, MySQL, etc.  many more. 
The C language uses a <studio.h> The C++ language uses a
Header Files
header file. <iostream.h> header file.
Access Modifiers No access modifiers are present in Access modifiers are used in C++
the C structure. structures.
Contd…

For dynamic memory allocation, C With C++, memory allocation can


provides the malloc() and calloc() be performed by a new operator,
Memory Allocation/De-allocation
functions, as well as free() function and memory de-allocation can be
for memory de-allocation. accomplished by a delete operator.
Inheritance Inheritance is not supported by C. Inheritance is supported in C++.
The C language focuses on Rather than focusing on methods
Focus methods or processes instead of or procedures, C++ focuses on data.
data.
The C language does not support
In C++, virtual functions and friend
Virtual and Friend functions virtual functions or friend functions are supported.
functions.

You might also like