-
A pointer is a construct that gives you more control of the computer's memory.
-
A pointer is the memory address of a variable.
-
An address that is used to name a variable is called a pointer because the address can be thought of as "pointing" to the variable.
-
The address "points" to the variable because it identifies the variable by telling where the variable is, rather than telling what the variable's name is.
-
Each pointer variable requires a different pointer type (i.e. a double can't point to an int).
-
The operator new can be used to create variables that have no identifiers to serve as their names.
-
The new operator produces a new, nameless variable and returns a pointer that points to this new variable.
-
Variables that are created using the new operator are called dynamic variables because they are created and destroyed while the program is running.
-
A special are of memory, called the freestore, is reserved for dynamic variables.
-
The delete operator eliminates a dynamic variable and returns the memory that the dynamic variable occupied to the freestore so that the memory can be reused.
-
Undefined pointer variables are called dangling pointers.
-
Variables created with the new operator are called dynamic variables, because they are created and destroyed while the program is running.
-
Ordinary variables are not called static variables.
-
The ordinary variables that we have been using are called automatic variables because their dynamic properties are controlled automatically for; they are automatically created when the function in which they are declared is called and automatically destroyed when the function call ends.
-
Global variables are variables that are declared outside of any function definition (including being outside of main).
-
You can use typedef to define an alias for any type name or definition.
typedef double Kilometers;
becomes
Kilometers distance;
-
There are 2 advantages in using defined pointer type names.
1. It avoids the mistake of omitting an asterisk.
2. It is seen when you define a function with a call-by-reference parameter for a pointer variable.
-
A pointer is a memory address, so a pointer provides a way to indirectly name a variable by naming the addresss of the variable in the computer's memory.
-
Dynamic variables are variables that are created (and destroyed) while a program is running.
-
Memory for dynamic variables is in a special portion of the computer's memory called the freestore.
-
When a program is finished with a dynamic variable, the memory used by the dynamic variable can be returned to the freestore for reuse; this is done with a delete statement.
|
|