T B H P N

C and C++ Language Comparison

"[In Unix] We have persistant objects, they're called files."
- Ken Thompson

Synopsis:

C++ is based on a C language core. Most C programs will compile as C++ programs. C++ adds:

Inheritance and templates allow us to build very flexible code that is easy to reuse and that gracefully accomodates changes in requirements. That only happens if you use good design practices.

These are excellent references for the C++ language:

Similarities between C and C++

Differences between C and C++

We will see examples of all of these C++ language artifacts in the code examples to follow.

C++ Philosophy:


  1. A stack frame is an allocation of stack memory provided by the process to a scope about to become active, e.g., the thread of execution is about to enter the scope. This allocation is valid only as long as the thread of execution is in that scope.
  2. C++ does not have an interface construct. However, a struct with:
    • no data members
    • no constructors
    • all pure virtual methods, except for a non-pure virtual destructor with empty body
    is semantically equivalent to the interface contracts in C# and Java. This "interface" serves to declare a contract for service provided by all classes that have this struct as a base, e.g., implement the interface.
CST strip