Skip to content

Latest commit

 

History

History
56 lines (32 loc) · 2.15 KB

c-vs-cpp.md

File metadata and controls

56 lines (32 loc) · 2.15 KB

C vs C++

C and C++ are two completely different standards.

C++ attempts to be as much as possible extension of C.

As such, when new C versions such as C99 come out, it is impossible that C++ will immediately follow, but it is very likely that the new C features will be incorporated into C++ if possible in the following versions.

Major differences include:

  • classes. Adds enormous complexity and capabilities to the language.
  • templates
  • stdlib containers
  • function overloading
  • namespaces

All of those features allow to:

  • drastically reduce code duplication
  • improve code structure

at the cost of:

  • adding huge complexity to the language.

    The C++ standards have twice as many pages as the C standards.

  • harder to track what assembly code is generated thus:

All things considered, C++ offers huge productivity boosts over C once you learn it...

It should be used on any new project, except if code efficiency is absolutely crucial, and even in those cases it might be worth it to have a C++ project that use C only features for the 20% critical sections.

C++11 N3337 standard draft Annex C

Not all behaviour changes in C++ from C are new features!

Some are just deprecation of archaic C ugliness.

This section of the C++ standard lists those differences.

Some examples: