Redirected from Cplusplus
|
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
.
#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; };
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.
Search Encyclopedia
|
Featured Article
|