T &ref = obj;
T *const ptr = &obj;
Is there any difference between these two declarations in C++ in terms of behavior?
I know that first one is called reference (whose members are accessed through dot (.) operator) and second one is called a pointer (whose members are access through arrow (->) operator).
But, if we consider their behavior, they both points to obj
and will not be able to point to any object other than the one they are initialized with. We can modify the content of obj
using both of them.
If both are same, which one is good for better coding style.