yea you got it, *x is a pointer and &y is a reference.
so x would "point" to the memory location of whatever its equal to.
lets say
1 2
int bill = 15;
int* x = bill;
the memory address of bill will be some address location and thats what x will be equal to, the memory address of bill.
ex. bill is stored at location 100A, x is equal to 100A.
if u use the & operator, you "dereference" the memory address, basically meaning you take whats actually at that memory location.
so int y = &x will give you 15.
try it out in a simple program and here's some more info about it if you still don't get it.
Yes, it does. Note that references must have an initializer.
tech junkie wrote:
int* x = bill; (sic)
Where's your address-of operator?
tech junkie wrote:
if u use the & operator, you "dereference" the memory address (sic)
Only pointers can be dereferenced. The address-of operator reveals the address of the first byte of the operand given to it; nothing more, nothing less. When the address-of operator is used in combination with pointers, the address-of operator is used to give the pointer an address to point to.
tech junkie wrote:
so int y = &x will give you 15. (sic)
No. In C++, a memory address and a int are two different things. Only pointers can refer to an address in memory.
Not really sure,(i'm still a nub after a couple years of c++(really :( )) but i thought that declaring a variable was saying something like "int x;" whereas defining it would be "x = 3"
Please don't take me word for word all the time. I like to imagine I have approximate knowledge of many things.