Is C++ a superset of C? What are the differences between C and C++? Can I use a
C++ compiler to compile C code?
C++ was derived from C, and is largely based on it, but there are some legal C constructs
which are not legal C++. Conversely, ANSI C inherited several features from C++,
including prototypes and const, so neither language is really a subset or superset
of the other; the two also define the meaning of some common constructs differently.
The most important feature of C++ not found in C is of course the extended structure
known as a class which along with operator overloading makes object-oriented programming
convenient. There are several other differences and new features: variables may
be declared anywhere in a block; const variables may be true compile-time constants;
structure tags are implicitly typedeffed; an & in a parameter declaration requests
pass by reference; and the new and delete operators, along with per-object constructors
and destructors, simplify dynamic data structure management. There are a host of
mechanisms tied up with classes and object-oriented programming: inheritance, friends,
virtual functions, templates, etc. (This list of C++ features is not intended to
be complete; C++ programmers will notice many omissions.)