Tutorial and Reference for the C++ Programming Language
C++ has its origin in the C language, but is rather a programming style than a new language, because most of the C language elemets are embedded in C++. This tutorial assumes some knowledge about C as the foundation. A quick introduction to the C language is also available on this site. A good reference book for more information is "C++ Primer" by S.B. Lippman and J. Lajoie.
C++ is always characterize by several key elements:
Information and methods to process the information are combined into objects. Instead of a monolithic line-by-line algorithm (e.g. C or Fortran), the overall algorithm is design how objects interacts with each other and exchange information (However, even C++ is not truely object-oriented, because it cannot deny its C origin. Truly object-oriented programs are e.g. Labview or Cocoa)
Information in C++ objects are protected against any direct manipulation from outside (other objects). Only methods and access functions are available. This is essential for large scale codes because it splits the 'interface' from its content (e.g. object methods can be altered and the program compiles as long as the interface remains unchanged.)
Objects can be used as a base for other objects. These derived objects inherits certain features of the base object, which then can be either extended or overwritten.
Multiple inheritance from the same base type allows to treat all these different objects as the same object type, namely that of the base object (e.g. a 'beam' is the base object to an 'electron beam' and 'radiation beam'. Although calculated differently the derived objects have certain attributes in common, such as mean energy, length and size).
C++ allows to redefine operators to act on objects to obtain a more readable code. (e.g. a and be are geometric vectors. The syntax a+b; is more readbale than a.x+b.x; a.y+b.y; a.z+b.z;
Functions and classes can be written as a template in a more generic manner. The same algorithm can be reused for different data types. In standard C it was required to rewritte the function of each data type.
Standard Template Library
A set of predefined class templates. The most importants one are the vector class, the string class and the complex class (the first two are improvements of the array type and the character type in C).