# Software Engineers Handbook/Language Dictionary/C++
## C++

C++ is an Multi-paradigmed programming language derived from C.

### Type

C++ is a full, Multi-paradigmed programming language implementing the following paradigmen: generic (template metaprogramming), imperative and object-oriented (class-based)

### Execution Entry Point

An executable starts with the main method.

### General Syntax

The typical statement is completed by a semi-colon. For the assignment of b to a use:

### Comments

Block comments are specified by a starting /* and ending */ They can span multiple lines.

### Variable Declarations

Declarations can appear anywhere in the implementation.
Declare i as an integer:
Here are two ways to declare i as an integer and give it an initial value of 0:

### Method Declaration/Implementation

Methods are declared by specifying the interface for the method. It is often declared within the scope of a class.
Method implementation repeats much of the same information
IMPORTANT POINT A beginner in C/C++ might get confused about the distinction between how pointers are declared in a function prototype vs. how the function is defined. For example, if my_function does not return anything, but accepts one floating point input, its function prototype looks as follows:
However, if the variable my_var is defined to be a pointer to a float, for example:
Then the manner in which my_function is invoked is as follows:
Beginners sometimes get confused about the fact that a "*" is used to tell the compiler in a prototype statement that a variable is a pointer, but a "*" is not syntactically used during invocation of a function that accepts a pointer as input.

### Scope

Scope is defined by curly braces.

### Conditional Statements

If and only if A is equal to B assign C to D, otherwise, assign E to F.
or
Alternatively, a switch statement can be used for multiple choice operations. This sample converts a number input to text.

### Looping Statements

This code counts from 0 to 9, adding up the contents of the array.
This code repeats until the number 4 is found. If this runs off of the end of the array, there could be a problem.
This code increments the counter before the check is made, so that it starts with element 1.

### Output Statements

or

### Containers

The standard template library has a variety of containers including vector, bit-set, list, map and multi-set.

### Algorithms

The standard template library has a variety of algorithms including sort, remove_if, and find_if.

### Garbage collection

Garbage collection is manual.

### Physical Structure

Generally the interfaces are defined in header files, often *.h. The implementation files are often named *.cpp. Useful collections of classes can be compiled into libraries, often *.dll, *.a, or *.so, which can be compiled into executables (statically linked) or used on the fly (dynamically linked).

### Tips

Don't confuse these two:
Often using the one you don't want will compile, and will produce results you did not expect.
A good practice is to write; if(CONSTANT == variable) rather than if(variable == CONSTANT) since the compiler will catch; if(CONSTANT = variable) but not if(variable = CONSTANT).
Arrays start with index 0.

### Web References

* C++ wikibooks

### Books and Articles

* Bruce Eckel, Thinking in C++, Volume 1: Introduction to Standard C++ ISBN 0139798099. It has helped many people make the leap from C to C++. It is available for free online at Bruce Eckel's site.
* Nicolai M. Josuttis, The C++ Standard Library : A Tutorial and Reference ISBN 0201379260. It contains lengthy and advanced discussions on the standard template library conatiners and algorithms.
* Stanley B. Lippman, Josée Lajoie & Barbara E. Moo, C++ Primer ISBN 0321714113. This is a very thorough introduction to C++, taking nearly 1000 pages to introduce programmers to C++.
* Andrew Koenig & Barbara E. Moo, Accelerated C++ ISBN 020170353X. This is another introduction to C++, but stresses the use of the STL. It is a quite compact introduction, with a steeper learning curve better suited for those who already know another programming language.
* Scott Meyers, Effective C++ ISBN 0321334876, More Effective C++ ISBN 020163371X, Effective STL ISBN 0201749629. Meyers' series of books contain the best C++ practices, from class design to minimising compilation dependencies.
* Herbert Schildt, C++: The Complete Reference ISBN 0072226803. It contains dictionary-like listings of code syntax and usage. The structure does not make it useful to learn the language from scratch. However, it could be very useful when switching from a similar language.
* Bjarne Stroustrup, The C++ Programming Language ISBN 0201889544. Written by the creator of C++, it covers everything from the core language to the standard library. The book itself has over 1300 pages.