I am trying to use a return type of const MyClass * const
. However, I get a warning:
Warning: #815-D: type qualifier on return type is m
One simple way of making sure you're defining the return type you want is to always add modifiers on the right (as opposed to left) side of original type.
MyClass // MyClass object
MyClass const // MyClass object which can't be modified
MyClass const & // reference of an unmodifiable MyClass object
MyClass const * // pointer to an unmodifiable MyClass object
MyClass const * const // unmodifiable pointer to an unmodifiable MyClass object
MyClass const * const & // reference of an unmodifiable pointer to an unmodifiable MyClass object
That should help make sure your return types are never meaningless again :)