What is the difference between C and C++?
C is a procedural language focused on functions and step by step logic. C++ is a superset of C that adds object oriented programming with classes and objects, along with features like references, function overloading, templates, exceptions, and the STL. Most valid C code also compiles as C++, but C++ offers far more ways to structure large programs.
- C is procedural and organised around functions, while C++ adds object oriented programming.
- C++ adds classes, references, overloading, templates, exceptions, and the STL.
- C++ is largely a superset of C, so most C programs also compile as C++.
The core difference
C organises code around functions and data separately. C++ lets you bundle data and behaviour into classes, which supports the four pillars of object oriented programming and makes large systems easier to manage.
Key features C++ adds
- Classes and objects for OOP.
- References in addition to pointers.
- Function and operator overloading.
- Templates for generic code and the STL.
- Exceptions for error handling.
The clean framing is C is procedural, C++ adds object oriented programming and more on top. Noting that C++ is largely a superset of C, so most C programs compile in C++, gives a memorable one line answer.
Frequently asked questions
What does it mean that C++ is a superset of C?
It means C++ includes most of C's syntax and features, so much valid C code compiles under C++, while C++ adds many features on top.
What are templates in C++?
Templates let you write generic code that works with any type, such as a container or function that operates on int, double, or a custom class.
Common follow up questions
Related interview questions
Want the full C++ guide?
Read every C++ concept with notes, diagrams, and code in one place. Track your progress as you go.
Open the C++ guide All C++ questions