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.

Technical overview

The 1998 C++ standard consists of two parts: the core language and the C++ standard library; the latter includes most of the Standard Template Library and a slightly modified version of the C standard library. Many C++ libraries exist which are not part of the standard, such as the Boost library. Also, non-standard libraries written in C can generally be used by C++ programs.

Related Topics:
1998 - Standard - Core language - C++ standard library - Standard Template Library - Boost library - C

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Features introduced in C++

Compared to C language, C++ introduced extra features, including declarations as statements, function-like casts, new/delete, bool, reference types, const, inline functions, default arguments, function overloading, namespaces, classes (including all class-related features such as inheritance, member functions, virtual functions, abstract classes, and constructors), operator overloading, templates, the :: operator, exception handling, and run-time type identification.

Related Topics:
Declarations - Namespaces

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

C++ also performs more type checking than C in several cases.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Comments starting with two slashes ("//") were originally part of C's predecessor, BCPL, and were reintroduced in C++.

Related Topics:
C - BCPL

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Several features of C++ were later adopted by C, including const, inline, declarations in for loops, and C++-style comments (using the // symbol). However, C99 also introduced

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

features that do not exist in C++, such as variadic macros and better handling of arrays as parameters.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

A very common source of confusion is a subtle terminology issue: because of its derivation from C, in C++ the term object means memory area, just like in C, and not class instance, which is what it means in most other object oriented languages. For example in both C and C++ the line

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

int i;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

defines an object of type int, that is the memory area where the value of the variable i will be stored on assignment.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

C++ library

The C++ standard library incorporates the C standard library with some small modifications to make it work better with the C++ language. Another large part of the C++ library is based on the Standard Template Library (STL). This provides such useful tools as containers (for example vectors and lists) and iterators (generalized pointers) to provide these containers with array-like access. Furthermore (multi)maps (associative arrays) and (multi)sets are provided, all of which export compatible interfaces. Therefore it is possible, using templates, to write generic algorithms that work with any container or on any sequence defined by iterators. As in C, the features of the library are accessed by using the #include directive to include a standard header. C++ provides sixty-nine standard headers, of which nineteen are deprecated.

Related Topics:
C++ standard library - Standard Template Library - Container - Vector - Lists - Iterator - Pointer - Associative array - Feature - Library - Directive - Standard header

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Because standard library was designed by leading experts and proven by the whole industry, it is recommended to use library's components instead of handcrafted counterparts or lower-level facilities. For example, using std::vector or std::string instead of plain old array will not only make life easier, but also helpfully write safer and more scalable software.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The STL was originally a third-party library from HP and later SGI, before its incorporation into the C++ standard. The standard does not refer to it as "STL", as it is merely a part of the standard library, but many people still use that term to distinguish it from the rest of the library (input/output streams (IOstreams), internationalization, diagnostics, the C library subset, etc.).

Related Topics:
HP - SGI

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

A project known as STLPort, based on the SGI STL, maintains an up-to-date implementation of the STL, IOStreams and strings. Other projects also make variant custom implementations of the standard library with various design goals. Every C++ compiler vendor or distributor includes some implementation of the library, since this is an important part of the standard and is expected by programmers.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~