C++
C++ (pronounced "see plus plus"), a multi-paradigm programming language, supports object-oriented programming. Bjarne Stroustrup of Bell Labs developed C++ during the 1980s, deriving it from the C programming language. Thanks in large part to the immense popularity of the C programming language, C++ became the most popular language throughout the 1990s. It is still very widely used in commercial development to this day. C++ replaced C as the commercial language of choice because it let programmers deal with ever-increasing complexity without abandoning their C legacy. Along with its object-oriented design, today's C++ differs from C in its support for generic programming and template metaprogramming; via alias types, in-line expansion, templates, and //-commenting (though note that C has subsequently adopted in-line expansion and //-commenting).
History of C++
Stroustrup began work on the language in 1979, inspired by Simula67. AT&T first used the language in August 1983. The original compiler was Cfront. The first commercial release occurred in October 1985. ISO/IEC 14882-1998 standardized C++ in 1998.
History of the Name "C++"
This name is credited to Rick Mascitti (mid-1983) and was first used in December 1983. Earlier, during the research period, the developing language had been referred to as "C with Classes". The final name stems from C's "++" operator (which increments the value of a variable) and a common naming convention of using "+" to indicate an enhanced computer program, for example: "Wikipedia+". According to Stroustrup: "the name signifies the evolutionary nature of the changes from C". C+ had earlier named an unrelated program. While most C code consists of valid C++, C does not form a subset of C++.
Some C programmers have noted that
if the statements x=3;
and y=x++;
are executed, then x==4
and y==3
; x
is incremented after its value is assigned to y
.
However, if the second statement is y=++x;
, then y=4
and x=4
.
Following such reasoning, a more proper name for C++ might actually be ++C. However, c++
and ++c
both increment c
, and, on its own line, the form c++
is more common than ++c
.
The pedantic may note that the introduction of C++ did not change the C language itself and the most accurate name might then be "C+1".
Ownership of C++
Nobody owns C++. Stroustrup and AT&T receive no royalties for the usage of C++.
"Hello Wikipedia!" Program
The below code can be compiled into a program which outputs a text message. See also: Hello world program
#include <iostream> // The <iostream> header is needed for std::cout // Beginning of main() function int main(int argc, const char**argv) { // { ... } is used to include blocks of code std::cout << "Hello, Wikipedia!\n"; // Outputs the text enclosed by "" return 0; }
Class definition
#include <string> using std::string; class InetMessage { string m_subject, m_to, m_from; public: InetMessage (const string& subject, const string& to, const string& from); string subject () const; string to () const; string from () const; };
C++ library
The C++ standard library mostly forms a superset of of the C standard library. A large part of the C++ library comprises the Standard Template Library (STL). The STL provides such useful tools as iterators (which resemble high-level pointers) and containers (which resemble arrays that can automatically grow to include new elements). As in C, the features of the library are accessed by using the #include
directive to include a standard header. C++ provides fifty non-deprecated standard headers.
Future Development
C++ continues to evolve to meet future requirments. While compiler vendors still struggle to support all of C++'s features (circa 2004), the situation improved significantly from 1998 to 2003. One group in particular works to make the most of C++ in its current form and advise the C++ standards committee which features work well and which need improving: Boost.org. Current work indicates that C++ will capitalize on its multi-paradigm nature more and more. The work at Boost.org, for example, is greatly expanding C++'s functional and meta programming capabilities. C++ still lacks a standard for name decoration, making object code produced by different compilers incompatible.