From C to C++ - different paradigms

C and C++ are two different programming paradigms, two different ways of thinking. In C, we use:

  • Raw arrays
  • Raw pointers
  • Macros
  • Pointer arithmetic
  • Character arrays

In C++, we should avoid the above entities and techniques. In C++, we use:

  • Smart pointers
  • Standard Library containers
  • Classes and templates
  • Strings
  • C++-specific idioms and techniques, for example - RAII

When moving from C to C++, we should adopt the following approach:

  • Try not to mix C with C++
  • Try not to write "C with Classes"
  • Try to adopt a new, C++-specific way of thinking
Posted on January 30, 2025, by

Slobodan Dmitrovic

Slobodan Dmitrovic is a software development consultant, C++ trainer, and author of several books on C and C++.