|
|
By Alex, on July 18th, 2007
In Chapter 1, we covered function basics in the following sections:
A first look at functions Forward declarations Programs with multiple files Header files
You should be familiar with the concepts discussed in those lessons before proceeding.
Parameters vs Arguments
Up until now, we have not differentiated between function parameters and arguments. In common . . . → Read More: 7.1 — Function parameters and arguments
By Alex, on July 17th, 2007
References and pointers
References and pointers have an interesting relationship — a reference acts like a const pointer that is implicitly dereferenced. Thus given the following:
int nValue = 5; int *const pnValue = &nValue; int &rnValue = nValue;
*pnValue and rnValue evaluate identically. As a result, the following two statements produce the same . . . → Read More: 6.12 — References vs. pointers, and member selection
By Alex, on July 16th, 2007
References are a type of C++ variable that act as an alias to another variable. A reference variable acts just like the original variable it is referencing. References are declared by using an ampersand (&) between the reference type and the variable name:
int nValue = 5; // normal integer int &rnRef = nValue; . . . → Read More: 6.11 — References
By Alex, on July 16th, 2007
Just like normal variables, pointers can be declared constant. There are two different ways that pointers and const can be intermixed, and they are very easy to mix up.
To declare a const pointer, use the const keyword between the asterisk and the pointer name:
int nValue = 5; int *const pnPtr = &nValue; . . . → Read More: 6.10 — Pointers and const
By Alex, on July 13th, 2007
All of the variables used up to this point in the tutorial have one thing in common: the variables must be declared at compile time. This leads to two issues: First, it’s difficult to conditionally declare a variable, outside of putting it in an if statement block (in which case it will go out . . . → Read More: 6.9 — Dynamic memory allocation with new and delete
|
|