What is the difference Between C and C++?

Following are some of the differences between C and C++.

  • When compared to C++, C is a subset of C++. All valid C programs are valid C++ programs.
  • C is a structural or procedural programming language, while C++ is an object oriented programming language.
  • In C, Functions are the fundamental building blocks, while in C++, Objects are the fundamental building blocks.
  • C doesn't have variable references, while C++ has variable references.
  • C uses malloc and free for memory allocation while C++ uses new and delete for memory allocation.
  • C does not provide direct support for error handling, while C++ supports exception handling that helps in error detection and smooth handling.
  • C does not support function and operator overloading, while C++ supports both function and operator overloading.
  • C doesn't support Generic programming, while templates in C++ allow to write generic programs.
  • C doesn't support namespaces while C++ supports them.