Did you intend class 'object' to contain a pointer to an array of data
of the same type? Or is it merely for the sake of example?
> };
>
While neither operator changes the contents of the object itself (the
pointer stays as it is), the logic suggests that the contents of memory
pointed to by the member (objArray) for an object declared 'const' are
not supposed to change either since they are *perceived* as the
"contents" (provided that the memory is somehow maintained by the object
itself and thus the *full responsibility* of the object).
To prevent the contents of the memory to which 'objArray' member points,
from being deliberately changed, the 'const' member function returns a
reference to const, while a non-const member function returns a
reference to a non-const object.
V
--
I do not respond to top-posted replies, please don't ask