You can try writing a program to do those, and see which ones the compiler thinks are illegal.
A
reference is a way of referring to another variable by giving it another name.
1 2 3
|
string george = "Hi! I'm George!";
string& jorge = george;
|
Both 'george' and 'jorge' are actually the
same variable. You've just managed to give them different names.
A
pointer is like a middleman. He just shows you where the one you want is.
1 2 3
|
string george = "Hi! I'm George!";
string* i_know_where_george_is = &george;
|
While 'george' is the variable that we want to play with, the 'i_know_where_george_is' variable helps us find him.
Finally, the
type of a thing matters. Some things can be automatically converted to another thing:
- a variable can be assigned to a reference:
int & ref = var;
Other things you cannot convert:
- a pointer != a referece:
int & ref = ptr; // NOO!
You must first follow the pointer:
int & ref = *ptr; // YES!
Hope this helps.