t wrote:
What should the correct form of the const version of operator-?
Lippman does something like:
const Item_base* operator->() const
I have another book (Mark Joshi's C++ Design Patterns and Derivatives
Pricing) that adds a 3rd const keyword, so he would write the line of
code above as:
const Item_base* const operator->() const
The top-level const (the one making Mark Joshi's variation different
from Lippman's) is irrelevant. The function returns an r-value of
"a pointer to a const Item_base". Such r-value is immutable anyway
(there is no mechanism that would provide a way to change it) hence
declaring it 'const' is meaningless.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask