++
From Wikipedia, the free encyclopedia
Jump to: navigation, search
C++
Paradigm:
multi-paradigm
Appeared in:
1985
Designed by:
Bjarne Stroustrup
Typing discipline:
Static, unsafe, nominative
Major implementations:
GNU Compiler Collection, Microsoft Visual C++, Borland C++ Builder
Dialects:
ANSI C++ 1998, ANSI C++ 2003
Influenced by:
C, Simula, Ada 83, ALGOL 68, CLU, ML
Influenced:
Ada 95, C#, Java, PHP, D, Aikido
C++ (pronounced "see plus plus", IPA: /siː plʌs plʌs/) is a general-purpose, programming language with high-level and low-level capabilities.[1] It is a statically typed, free-form, multi-paradigm, usually compiled 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.[citation needed]
C++ is regarded as a mid-level language. This indicates that C++ is comprised of a combination of both high-level and low-level language features.
Bjarne Stroustrup developed C++ (originally named "C with Classes") in 1983 at Bell Labs as an enhancement to the C programming language. Enhancements started with the addition of classes, followed by, among other features, virtual functions, operator overloading, multiple inheritance, templates, and exception handling. The C++ programming language standard was ratified in 1998 as ISO/IEC 14882:1998, the current version of which is the 2003 version, ISO/IEC 14882:2003. A new version of the standard (known informally as C++0x) is being developed.
Contents[hide]
1 History
1.1 The name "C++"
1.2 Future development
2 Philosophy
3 Standard library
4 Features introduced in C++
5 Hello world program
6 Language features
6.1 Operators
6.2 Preprocessor
6.3 Templates
6.4 Objects
6.4.1 Encapsulation
6.4.2 Inheritance
6.5 Polymorphism
6.5.1 Static polymorphism
6.5.2 Dynamic polymorphism
7 Parsing and processing C++ source code
8 Problems and controversies
9 Incompatibility with C
10 See also
11 Notes
12 References
13 External links
//
[edit] History
Stroustrup began work on C with Classes in 1979. The idea of creating a new language originated from Stroustrup's experience in programming for his Ph.D. thesis. Stroustrup found that Simula had features that were very helpful for large software development, but the language was too slow for practical use, while BCPL was fast but too low-level and unsuitable for large software development. When Stroustrup started working in Bell Labs, he had the problem of analyzing the UNIX kernel with respect to distributed computing. Remembering his Ph.D. experience, Stroustrup set out to enhance the C language with Simula-like features. C was chosen because it is general-purpose, fast, and portable. Besides C and Simula, some other languages which inspired him were ALGOL 68, Ada, CLU and ML. At first, the class, derived class, strong type checking, inlining, and default argument features were added to C via Cfront. The first commercial release occurred in October 1985.[2]
In 1983, the name of the language was changed from C with Classes to C++. New features were added including virtual functions, function name and operator overloading, references, constants, user-controlled free-store memory control, improved type checking, and BCPL style single-line comments with two forward slashes (//). In 1985, the first edition of The C++ Programming Language was released, providing an important reference to the language, as there was not yet an official standard. In 1989, Release 2.0 of C++ was released. New features included multiple inheritance, abstract classes, static member functions, const member functions, and protected members. In 1990, The Annotated C++ Reference Manual was published. This work became the basis for the future standard. Late addition of features included templates, exceptions, namespaces, new casts, and a Boolean type.
As the C++ language evolved, a standard library also evolved with it. The first addition to the C++ standard library was the stream I/O library which provided facilities to replace the traditional C functions such as printf and scanf. Later, among the most significant additions to the standard library, was the Standard Template Library.
After years of work, a joint ANSI-ISO committee standardized C++ in 1998 (ISO/IEC 14882:1998). For some years after the official release of the standard in 1998, the committee processed defect reports, and published a corrected version of the C++ standard in 2003. In 2005, a technical report, called the "Library Technical Report 1" (often known as TR1 for short) was released. While not an official part of the standard, it gives a number of extensions to the standard library which are expected to be included in the next version of C++. Support for TR1 is growing in almost all currently maintained C++ compilers.
While the C++ language is royalty-free, the standard document itself is not freely available.
[edit] The name "C++"
This name is credited to also Rick Mascitti (mid-1983) and was first used in December 1983. Earlier, during the research period, the developing language had been referred to as "new C", then "C with Classes". In computer science C++ is still referred to as a superstructure of C. 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. According to Stroustrup: "the name signifies the evolutionary nature of the changes from C". C+ was the name of an earlier, unrelated programming language.
Stroustrup addresses the origin of the name in Chapter 1 of his book, The C++ Programming Language, remarking that another interpretation of the C++ name could be seen from the appendix of George Orwell's Nineteen Eighty-Four. Of the three segments of the fictional language Newspeak, the "C vocabulary" is the one dedicated to technical terms and jargon. "Doubleplus" is the superlative modifier for Newspeak adjectives. Thus, "C++" might hold the meaning "most C-like" in Newspeak.
When Rick Mascitti was questioned informally in 1992 about the naming, he indicated that it was given in a tongue-in-cheek spirit. He never thought that it would become the formal name of the language.
A common joke about the name is that in C++, when ++ is used as a postfix operator the variable is incremented only after its value has been used (hence, for this reason and to match the double-plus Newspeak usage described above, it should be ++C rather than C++).
[edit] Future development
C++ continues to evolve to meet future requirements. A new version of the C++ standard is currently being worked on, entitled C++0x, denoting that it is expected to be released before 2010. Current work indicates that C++ will continue to capitalize on its multi-paradigm nature. Notable expected improvements are native support for threading and concepts, which will make working with templates easier. More controversially, adding garbage collection is currently under heavy discussion. Boost.org is a group working to make the most of C++ in its current form. They are greatly expanding C++'s functional and metaprogramming abilities. They also advise the C++ standards committee on which features work well and which need improving.
[edit] Philosophy
In The Design and Evolution of C++ (1994), Bjarne Stroustrup describes some rules that he uses for the design of C++. Knowing the rules helps to understand why C++ is the way it is. The following is a summary of the rules. Much more detail can be found in The Design and Evolution of C++.
C++ is designed to be a statically typed, general-purpose language that is as efficient and portable as C
C++ is designed to directly and comprehensively support multiple programming styles (procedural programming, data abstraction, object-oriented programming, and generic programming)
C++ is designed to give the programmer choice, even if this makes it possible for the programmer to choose incorrectly
C++ is designed to be as compatible with C as possible, therefore providing a smooth transition from C
C++ avoids features that are platform specific or not general purpose
C++ does not incur overhead for features that are not used
C++ is designed to function without a sophisticated programming environment
"Inside the C++ Object Model" (Lippman, 1996) describes how compilers may convert C++ program statements into an in-memory layout. Compiler authors are free to implement the standard in their own manner.
[edit] Standard library
The 1998 ANSI/ISO C++ standard consists of two parts: the core language and the C++ standard library; the latter includes most of the Standard Template Library (STL) and a slightly modified version of the C standard library. Many C++ libraries exist which are not part of the standard, and, using linkage specification, libraries can even be written in languages such as C, Fortran, Pascal, or BASIC. Note: supported languages is compiler dependant.
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 STL. This provides such useful tools as containers (for example vectors and lists), iterators (generalized pointers) to provide these containers with array-like access and algorithms to perform operations such as searching and sorting. 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 69 standard headers, of which 19 are deprecated.
Using the standard library -- for example, using std::vector or std::string instead of a C-style array -- can help lead to 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, internationalization, diagnostics, the C library subset, etc.).
Most C++ compilers provide an implementation of the C++ standard library, including the STL. Compiler-independent implementations of the STL, such as STLPort, also exist. Other projects also produce various custom implementations of the C++ standard library and the STL with various design goals.
[edit] Features introduced in C++
Compared to the C language
Friday, July 20, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment