operator! and lvalue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In Thinking in C++ chapter on overloading operators, Bruce Eckel gives
the following code:

For a non-member operator:

int operator!(const Integer& a) {
  cout << "!Integer\n";
  return !a.i;
}

For a member operator:

Byte operator!() const {
  cout << "!Byte\n";
  return Byte(!b);
}

My question is: why is there no "const" before Integer and Byte at the
head of the function? There's all that stuff about when temporaries are
returned they are automatically const, but throughout the examples in
this chapter, only operator! is not explicitly specified to have a const
return value whereas in all other relevant cases we have the "const"
specified explicitly.

Shriramana Sharma.



-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux