Reference types - How to differentiate "reference" with "address of a variable"
int num = 3;
int &refNum = num; // ampersand & is on the left hand side of the assignment
// this is reference to variable num
// is an alias to num
// address of num and refNum should be the same when ouput
// cout << &refNum << and << &num
// any change in num (e.g num ++ ) will affect refNum and inversly,
// any change in refNum (e.g refNum++) will affect num
int *pNum = # // ampersand & is on the right hand side of the assignment
// this is for taking the address of variable num
So how to differentiate in which case, & is used as an alias (reference) or to take the address of a variable? Let's have a look on the above code