Microsoft Store
 

C plus plus


 

C++ (pronounced "see plus plus", IPA: /si? pl?s pl?s/) is a general-purpose computer programming language. It is a statically typed free-form multi-paradigm language supporting procedural programming, data abstraction, object-oriented programming, and generic programming. Since the 1990s, C++ has been one of the most popular commercial programming languages.

C++ is not a superset of C

While much C source code will compile as C++ code without issue, certain language differences prevent C++ from being a superset of C. For example, C++ forbids calling the 'main' function from within the program, whereas this is legal in C. In addition, C++ is much stricter about various features; for example, it lacks implicit type conversion between unrelated pointer types and does not allow a function to be used that has not yet been declared.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

A common portability issue from C to C++ are the numerous additional keywords that C++ introduced. This makes C code that uses them as identifiers illegal in C++. For example:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

struct template {

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

int new;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

struct template *class;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

};

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

is legal C code, but is rejected by a C++ compiler, since the keywords "template", "new" and "class" are not appropriate in the corresponding places.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The differences even extend to issues of style. For example the old, traditional, way of declaring function arguments in C is not supported at all by C++. The declaration:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

int subtract(minuend, subtrahend)

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

int minuend;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

int subtrahend;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

return minuend - subtrahend;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

}

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

would be rejected by a C++ compiler which, unlike C, demands that the following, newer, style to be used:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

int subtract(int minuend, int subtrahend)

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

return minuend - subtrahend;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

}

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

See the relation to C++ section of the C article for more details.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~