Encyclopedia > C plus plus

  Article Content

C Plus Plus

Redirected from C plus plus

C++ (pronounced "see plus plus") is a multi-paradigm programming language, which supports object-oriented programming; developed, during the 1980s, by Bjarne Stroustrup of Bell Labs. C++ is derived from C. C++ was standardized in 1998 (ISO/IEC 14882-1998[?]). Along with it's object-oriented design, C++ is distinguished from C with its support for generic programming[?] and template metaprogramming; via alias types[?], in-line expansion, templates, and //-commenting. In-line expansion and //-commenting were added to C, as part of the C99 update.

Table of contents

History of C++ Stroustrup began work on the language in 1979, inspired by Simula67[?], and the language was first used, by AT&T, in August 1983. The original compiler was Cfront. The first commercial release was in October 1985.

History of the Name "C++" While most C is valid C++, C is not a subset of C++; although, the names do indicate a distinct relationship. This name is credited to Rick Mascitti[?] (mid-1983) and was first used in December '83. Earlier, during the research period, the developing language had been referred to as "C with Classes". The 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+[?] was earlier used as the name for an unrelated program.

Some C programmers have noted that if the statements x=3; and y=x++; are executed, then x==4 and y==3. 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, other C programmers do use the expression "c++" to increment the variable "c".

Ownership of C++ Nobody owns C++. Stroustrup and AT&T are not paid 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
 
int main() // Beginning of main() function
{          // { ... } is used to include blocks of code
    std::cout << "Hello, Wikipedia!\n"; // Outputs the text enclosed by ""
}

Note that older (non-standard) C++ compilers (such as Borland C++ 5.02[?]) usually require <iostream.h> instead of the standard <iostream>, and cout instead of std::cout.

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 is mostly 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 are like high-level pointers) and containers (whuch are like 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. There are fifty non-deprecated standard headers provided in C++:

  • <algorithm>
  • <bitset>
  • <cassert>
  • <cctype>
  • <cerrno>
  • <cfloat>
  • <ciso646>
  • <climits>
  • <clocale>
  • <cmath>
  • <complex>
  • <csetjmp>
  • <csignal>
  • <cstdarg>
  • <cstddef>
  • <cstdio>
  • <cstdlib>
  • <cstring>
  • <ctime>
  • <cwchar>
  • <cwctype>
  • <deque>
  • <exception>
  • <fstream>
  • <functional>
  • <iomanip>
  • <ios>
  • <iosfwd>
  • <iostream>
  • <istream>
  • <iterator>
  • <limits>
  • <list>
  • <locale>
  • <map>
  • <memory>
  • <new>
  • <numeric>
  • <ostream>
  • <queue>
  • <set>
  • <sstream>
  • <stack>
  • <stdexcept>
  • <streambuf>
  • <string>
  • <typeinfo>
  • <utility>
  • <valarray>
  • <vector>

The headers of the form <cfoo> correspond to the C headers of the form <foo.h> (except for <complex>, which is new in C++). These C headers are also allowed in C++, but are deprecated. A compatibility header <strstream> is also provided and deprecated.

External Links



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Great River, New York

... area of 13.1 km² (5.1 mi²). 11.9 km² (4.6 mi²) of it is land and 1.2 km² (0.4 mi²) of it is water. The total area is 8.91% water. ...

 
 
 
This page was created in 26.2 ms