This is a discussion on Differene between reference object and value object within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by csonx_p Oh, now you making interesting comment to me here ... So in some regard, one can ...
If we were using pointers, it would be Address * const add - that is, the pointer itself can not change, but the content can.
However, _I_ still think you should use a Address member, not a reference - there is no point in using a reference here - you still need an address, and the address itself is not a free-standing object that makes any sense. So storing the address in full inside the driver is a fine thing to do.
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
A const function is, simply put, a function that promises to never change the internal state of the class*.
And as some have mentioned, references cannot be reassigned.
*) It's actually possible to make an exception to what const functions MAY modify in a class, but let's ignore that for now.Code:int a = 10; int b = 20; int& x = a; x = 30; x = b; // Oops, assigns 20 (the contents of b) to a. x = 40; // Oops, assigns 40 to a, not b.