I am currently going through the Getting started with C++ learning path on LinkedIn. I had some confusions regarding pointers and references so I visited this link on SO.
This link further confuses me, because based on the course the syntax for references is type followed by ampersand. ie int& my_reference = my_int;
However, i see posters using int& or float &sum = total;
on that link. This confuses me as I cant tell if it is reference or address of operator for pointers.
and if float &sum = total;
is valid declaration of a reference, is it that address of operator for pointers is only valid on the RHS of the expression? Meaning I cannot manually allocate the address of a variable to some other address as follows int &my_int = [new address here]
, but a pointer that points to memory address is allowed ptr = &my_int;
?