Ok, I'm trying to see if I understand points correctly. Here is how I understand them:
1) Pointers act as a variable that points to the memory adress of another variable:
Code:
int a = 10;
int *b= &a;
2) When dereferenced, you can output the value of the variable the pointer references:
Code:
std::cout<<*b<<endl;
OUTPUT: 10
3) When not dereferenced, you can output the memory adress of the variable the point references. Which can later be used to read the memory of a variable from another application (such as in a minesweeper cheat):
Code:
std::cout<<b<<endl;
OUTPUT: *bunch of hex*
4) Pointers can be used to pass by reference, so that a variable can be modified by a function without having to return it - allowing for the modification of multiple variable within a function:
Code:
int inc(int a, int *b)
{
a++:
*b = 20;//Is this legal?
return a;
}
int f = 0;
int g = 1;
inc(f, &g)//f is now 1, g is now 20
Ok, that's all I can think of right now. However, I want to know if I am right on those four points, and if there is anything else I should know.
EDIT: Yeah yeah, this is the 5 trillionth post on pointers, I know. However, unless I ask myself I won't be sure