Is this a pointer or a reference?

int x = 100;
int xx;
int *pointer;

pointer = &x
xx = *pointer;

I am getting confused myself so im asking here to make it clear to myself. Is this a pointer or a reference? What is the difference in syntax if i wanted to do the other.
a pointer IS a variable that is a reference to another variable (which references its address). So yes, "pointer" is a pointer. It is referencing the address of "x". Does that answer your question? Take a look here: http://www.cplusplus.com/doc/tutorial/pointers/
'pointer' is a pointer, if you wanted it to be a reference, the syntax would be the following:
1
2
3
4
5
int x = 100;
int xx;
int &referece = x;

xx = reference;

To declare a reference you must use an & instead of the * used for pointers.
References are always valid so they must be initialized ( you can't declare a reference without binding it to a variable.
After that, a reference acts exactly as the referenced object would.
Thank you for the input and i get it now i hope hahaha
Topic archived. No new replies allowed.