Operators

C++ uses infix operators. These are simply parsed as you would expect. You can also use parenthesis to make sure about the order of precidence. There are three main types of operators. Boolean, aritmetic, and binary. There are also the address and dereference operators which we just discussed for pointers.

Boolean are simple, they all return one or zero depending on if they are true or false respectively. They also cast properly to the bool type. They are || for or, and && for and. The comparisons to get a binary result are < > <= >= == and !=. Note that the boolean comparison == operator is NOT the same as the assignment = operator.

Arithmitic operators are * / - and +. Note that - can be either a unary or regular operation. All of the operations are strongly typed, however this is only important for division. If you are dividing two integers, you are doing integer division. This means that the computer will truncate the result. This is obviously not what you always want, so be sure to cast up to the correct type before doing division.

There are more arithitic operators as well, such as the assignment operator =, and a bunch a manipulative operators. += -= *= /= ++ and --. These allow you to change the value of the variable without using the variable twice. The following are all equivilent:

x = x - 1;
x -= 1;
x--;
You get the idea. If you want to know more about these you can look them up, but they are pretty simple, and not all that useful.

Return Value

This is the type of the value returned. You have to have a return line if you return some value. You can have no return value, in which case the type is of type void.

Function Name

This is the name of the function. It can be anything that starts with a letter.

Parameters

The function has parameters. The parameters are typed and need to have the type in from of the parameter names. The parameters are separated by commas.

Body

The function body is just normal C++ code surrounded by curley brackets. A function body can be as long or as short as you need. Generally you don't want your functions to be too long, or they are very hard to read.

Function Use

Functions often return a value. You can then use this value in an expression; for example, you can set the value of a variable with the return value of a function. Since C++ is strongly typed, you need to have the variable be the same type as the return type and all of the things you are passing the function be the correct type as well. Here is an example of the above function being called:
// using the add function
int theResult = 0;
int a = 10, b = 20;
theResult = add(a,b);
// theResult is now 30