Difference Between C and C++ With Example. C Vs C++
Difference Between C and C++ With Example. C Vs C++
com
Programming Tutorials and Interview Questions
Home
C Programming
Java Programming
Data Structures
Web Development
Tech Interview
The major difference between C and C++ is that C is a procedural programming language and
does not support classes and objects, while C++ is a combination of both procedural and object
oriented programming language; therefore C++ can be called a hybrid language. The following
table presents differences between C and C++ in detail.
C was developed by Dennis Ritchie between C++ was developed by Bjarne Stroustrup in
1969 and 1973 at AT&T Bell Labs. 1979 with C++'s predecessor "C with Classes".
When compared to C++, C is a subset of C++. C++ is a superset of C. C++ can run most of C
code while C cannot run C++ code.
In C, data are free entities and can be In C++, Encapsulation hides the data to
manipulated by outside code. This is because ensure that data structures and operators are
C does not support information hiding. used as intended.
C does not support function and operator C++ supports both function and operator
overloading. overloading.
C does not allow functions to be defined In C++, functions can be used inside a
inside structures. structure.
C does not have namespace feature. C++ uses NAMESPACE which avoid name
collisions.
C uses functions for input/output. For C++ uses objects for input output. For
example scanf and printf . example cin and cout .
C has no support for virtual and friend C++ supports virtual and friend functions.
functions.
C provides malloc() and calloc() functions C++ provides new operator for memory
for dynamic memory allocation, and free() allocation and delete operator for memory
for memory de-allocation. de-allocation.
C does not provide direct support for error C++ provides support for exception handling.
handling (also called exception handling) Exceptions are used for "hard" errors that
make the code incorrect.
Hope you have enjoyed reading differences between C and C++. This comparison of C and C++
explains feature-wise difference between both programming languages. Please do write us if
you have any suggestion/comment or come across any error on this page. Thanks for reading!
References
1. Kernighan and Ritchie, The C Programming Language, 2nd Ed.
2. C: The Complete Reference
3. Randal E. Bryant, David R. O'Hallaron, Computer Systems: A Programmer's Perspective.
Add a comment...
Munnaf M Abdul Doctoral Research Fellow in Precision Soil & Crop Engineering (SiTeMan) at Gent
University
As a beginer, What should I follow C or C++?
Like · Reply · Mark as spam · 1 · Sep 14, 2016 10:19am
Omar Masri
i would request C++ its much easier and more used , i'm a begginer too and im learning C++
Like · Reply · Mark as spam · Apr 26, 2017 3:57pm
Ope Wiji
bruh, both C and C++ have versions.. for example ANSI C, ISO C, C99, C11, and C++98, C++11,
C++14, etc..
starting C99 version what you're asking is supported and syntax for(int i=0;i<n;i++) {} will be
compiled ok
Like · Reply · Mark as spam · 1 · Oct 19, 2017 7:31am · Edited
Email:
Subscribe
85 26 72
A smartphone that recognises objects is tested by using it to try to stop a car running over a
dog.
In a Reddit thread, the Microsoft founder expresses his concerns about digital currencies like
Bitcoin.
The AI code found quirks in the Atari game code that let it score a lot of points, researchers
found.