+ All Categories
Home > Documents > C++ Project

C++ Project

Date post: 30-Oct-2014
Category:
Upload: mohit-kumar
View: 41 times
Download: 0 times
Share this document with a friend
Description:
Details of languageand Importance
Popular Tags:
15
LOADING Load Completed
Transcript
Page 1: C++ Project

LOADING

Load Completed

Page 2: C++ Project

ABOUT C++:-Paradigm(s) Multi - paradigm:procedural, object-oriented, generic

Appeared in 1983

Designed by Bjarne Stroustrup

Developer Bjarne Stroustrup

Bell Labs

ISO/IEC JTC1/SC22/WG21

Stable release

ISO/IEC 14882:2011 (2011)

Typing discipline Static, unsafe, nominative

Major implementations

C++ Builder, clang, Comeau C/C++, GCC, Intel C++ Compiler, Microsoft Visual C++, sun studio

Dialects

ISO/IEC C++ 1998

ISO/IEC C++ 2003

ISO/IEC C++ 2011

Influenced by

C, Simula, Ada 83, ALGOL 68, CLU, ML[1]

Influenced

Perl, LPC, Lua, Pike, Ada 95, Java, PHP, D, C99, C#,[2] Falcon

OS

Cross - platform (multi-platform)

- Usual filename extensions

.h .hh .hpp .hxx .h++ .cc .cpp .cxx .c++

Page 3: C++ Project

C++ (pronounced "cee plus plus") is a statically typed, free-form, multi-paradigm, compiled, general-purpose

programming language. It is regarded as an intermediate-level language, as it comprises a combination of both

high-level and low-level language features.It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs as

an enhancement to the C language. Originally named C with Classes, the language was renamed C++ in 1983,

as a pun involving the increment operator.

C++ is one of the most popular programming languages with application domains including systems software,

application software, device drivers, embedded software, high-performance server and client applications, and

entertainment software such as video games. Several groups provide both free and proprietary C++ compiler

software, including the GNU Project, Microsoft, Intel and Embarcadero Technologies. C++ has greatly influenced

many other popular programming languages, most notably C# and Java.

C++ is also used for hardware design, where the design is initially described in C++, then analyzed,

architecturally constrained, and scheduled to create a register-transfer level hardware description language via

high-level synthesis.

The language began as enhancements to C, first adding classes, then virtual functions, operator overloading,

multiple inheritance, templates, and exception handling among other features. After years of development, the

C++ programming language standard was ratified in 1998 as ISO/IEC 14882:1998. The standard was amended

by the 2003 technical corrigendum, ISO/IEC 14882:2003. The current standard extending C++ with new features

was ratified and published by ISO in September 2011 as ISO/IEC 14882:2011 (informally known as C++11).

C++:

Page 4: C++ Project

HISTORY:Bjarne 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 to be suitable for large software development. When Stroustrup started working in AT&T 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 was

general-purpose, fast, portable and widely used. Besides C and Simula, some other languages that 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 Stroustrup's C++ to C compiler, Cfront. The first commercial implementation

of C++ was released on 14 October 1985.

C++ is sometimes called a hybrid language.

It is possible to write object oriented or procedural code in the same program in C++. This has caused some concern

that some C++ programmers are still writing procedural code, but are under the impression that it is object

oriented, simply because they are using C++. C++ continues to be used and is one of the preferred programming

languages to develop professional applications.

Page 5: C++ Project

etymology: According to Stroustrup: "the name signifies the evolutionary nature of the changes from C". During C++'s

development period, the language had been referred to as "new C", then "C with Classes". The final name is credited to Rick Mascitti (mid-1983) and was first used in December 1983. When Mascitti was questioned informally in 1992 about the naming, he indicated that it was given in a tongue-in-cheek spirit. It 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. There is no language called "C plus". ABCL/c+ was the name of an earlier, unrelated programming language.

Standardization

Year C++ Standard Informal name

2011 ISO/IEC 14882:2011[16] C++11

2007 ISO/IEC TR 19768:2007[17] C++TR1

2003 ISO/IEC 14882:2003[18] C++03

1998 ISO/IEC 14882:1998[19] C++98

In 1998, the C++ standards committee (the ISO/IEC JTC1/SC22/WG21 working group) standardized C++ and published the international standard ISO/IEC 14882:1998 (informally known as C++98).[citation needed] For some years after the official release of the standard, the committee processed defect reports, and published a corrected version of the C++ standard, ISO/IEC 14882:2003, 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 specified a number of extensions to the standard library, which were expected to be included in the next version of C++. Support for TR1 is growing in almost all currently maintained C++ compilers.

The latest major revision of the C++ standard, C++11, (formerly known as C++0x) was approved by ISO/IEC on 12 August 2011.[20] It has been published as 14882:2011.

Page 6: C++ Project

Philosophy:In The Design and Evolution of C++ (1994), Bjarne Stroustrup describes some rules that he used

for the design of C++:[page needed]

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 (the "zero-overhead principle")

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, however, free to implement the

standard in their own manner.

Page 7: C++ Project

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.

The C++ standard library incorporates the C standard library with some small modifications to

make it optimized 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 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 72 standard headers, of which 17 are deprecated.

Most C++ compilers provide an implementation of the C++ standard library, including the STL.

Compiler-independent implementations of the STL, such as STLPort,[22] also exist. Other projects

also produce various custom implementations of the C++ standard library and the STL with various

design goals.

Page 8: C++ Project

Language features:

C++ inherits most of C's syntax. The following is Bjarne Stroustrup's version of the Hello world program that uses the C++ Standard Library stream facility to write a message to standard output:

#include <iostream>

int main()

{ std::cout << "Hello, world!\n"; }

Within functions that define a non-void return type, failure to return a value before control reaches the end of the function results in undefined behaviour (compilers typically provide the means to issue a diagnostic in such a case). The sole exception to this rule is the main function, which implicitly returns a value of zero.

Page 9: C++ Project

Operators and operator overloading:

C++ provides more than 35 operators, covering basic arithmetic, bit manipulation, indirection, comparisons, logical operations and others. Almost all operators can be overloaded for user-defined types, with a few notable exceptions such as member access (. and .*) as well as the conditional operator. The rich set of overloadable operators is central to using C++ as a domain-specific language. The overloadable operators are also an essential part of many advanced C++ programming techniques, such as smart pointers. Overloading an operator does not change the precedence of calculations involving the operator, nor does it change the number of operands that the operator uses (any operand may however be ignored by the operator, though it will be evaluated prior to execution). Overloaded "&&" and "||" operators lose their short-circuit evaluation property.

Operators that cannot be overloaded

Operator Symbol

Scope resolution operator  ::

Conditional operator  ?:

Member selection operator  .*

"sizeof" operator  sizeof

Page 10: C++ Project

object:C++ introduces object-oriented programming (OOP) features to C. It offers classes, which provide the four features commonly present in OOP (and some non-OOP) languages: abstraction, encapsulation, inheritance, and polymorphism. Objects are instances of classes created at runtime. One distinguishing feature of C++ classes compared to classes in other programming languages is support for deterministic destructors, which in turn provide support for the Resource Allocation is Initialization concept.

Encapsulation is the hiding of information in order to ensure that data structures and operators are

used as intended and to make the usage model more obvious to the developer. C++ provides the

ability to define classes and functions as its primary encapsulation mechanisms. Within a class,

members can be declared as either public, protected, or private in order to explicitly enforce

encapsulation.The OO principle is that all of the functions (and only the functions) that access the

internal representation of a type should be encapsulated within the type definition. Therefore, C++

supports not just OO programming, but other weaker decomposition paradigms, like modular

programming.

Encapsulation:

Page 11: C++ Project

Inheritance:

Inheritance allows one data type to acquire properties of other data types. Inheritance from a base

class may be declared as public, protected, or private. This access specifier determines whether

unrelated and derived classes can access the inherited public and protected members of the base

class. Only public inheritance corresponds to what is usually meant by "inheritance". If the access

specifier is omitted, a "class" inherits privately, while a "struct" inherits publicly. Base classes may

be declared as virtual; this is called virtual inheritance. Virtual inheritance ensures that only one

instance of a base class exists in the inheritance graph, avoiding some of the ambiguity problems

of multiple inheritance.

Page 12: C++ Project

Polymorphism:

Polymorphism enables one common interface for many implementations, and for objects to act

differently under different circumstances.

C++ supports several kinds of static (compile-time) and dynamic (run-time) polymorphisms.

Compile-time polymorphism does not allow for certain run-time decisions, while run-time

polymorphism typically incurs a performance penalty.

Static polymorphism

Function overloading allows programs to declare multiple functions having the same name (but

with different arguments). The functions are distinguished by the number or types of their formal

parameters. Thus, the same function name can refer to different functions depending on the

context in which it is used. The type returned by the function is not used to distinguish overloaded

functions and would result in a compile-time error message.

Dynamic polymorphism

C++ also provides a dynamic_cast operator, which allows the program to safely attempt

conversion of an object into an object of a more specific object type (as opposed to conversion to a

more general type, which is always allowed). This feature relies on run-time type information

(RTTI).

Page 13: C++ Project

Virtual member functions:

Ordinarily, when a function in a derived class overrides a function in a base class, the function to

call is determined by the type of the object. A given function is overridden when there exists no

difference in the number or type of parameters between two or more definitions of that function.

Hence, at compile time, it may not be possible to determine the type of the object and therefore

the correct function to call, given only a base class pointer; the decision is therefore put off until

runtime. This is called dynamic dispatch. Virtual member functions or methods allow the most

specific implementation of the function to be called, according to the actual run-time type of the

object.

A member function can also be made "pure virtual" by appending it with = 0 after the closing

parenthesis and before the semicolon. A class containing a pure virtual function is called an

abstract data type. Objects cannot be created from abstract data types; they can only be derived

from. Any derived class inherits the virtual function as pure and must provide a non-pure definition

of it (and all other pure virtual functions) before objects of the derived class can be created. A

program that attempts to create an object of a class with a pure virtual member function or

inherited pure virtual member function is ill-formed.

Page 14: C++ Project

compatibility:Producing a reasonably standards-compliant C++ compiler has proven to be a difficult task for compiler vendors in general.

In order to give compiler vendors greater freedom, the C++ standards committee decided not to dictate the implementation of name mangling, 

exception handling, and other

implementation-specific features.

The downside of this decision is that object code

 produced by different compilers is expected to be

incompatible.

There were, however, attempts to standardize

compilers for particular machines or operating

systems(for example C++ ABI), though they

seem to be largely abandoned now.

Page 15: C++ Project

criticism:Due to its large feature set and oft-perceived "strict" syntax, the language is sometimes criticized

as being overly complicated and thus difficult to fully master.Because it includes most of the C

programming language as a subset, C++ also inherits many of the criticisms leveled at C.

Other criticisms stem from missing features of C++'s standard library, such as the lack of "native" multithreading facilities—a feature present in

some other languages, including Ada, C#, and

Java (see Lock). In the specific case of

threading, the most recent revision to the

standard, C++11, corrects this omission.

Another point of criticism is the feature of

multiple inheritance, as such ontologies are

difficult to maintain.[citation needed]

—Bjarne Stroustrup, comp.lang.c++


Recommended