Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Constantly Confusing ‘const’. Parent comment
Assume you have a class Foo, and this:
const Foo fooInst(1, 2, 3);
if you try to call a method foo.bar() you can't, unless that method bar() is also marked const with this type of signature:
int bar() const;
Meaning that bar returns an int, but can't assign to any fields or call any other non-const methods.
Although, it does have this hideous const_cast<> operator that anyone can use to break these rules.
There are no comments on this comment yet.
Assume you have a class Foo, and this:
const Foo fooInst(1, 2, 3);
if you try to call a method foo.bar() you can't, unless that method bar() is also marked const with this type of signature:
int bar() const;
Meaning that bar returns an int, but can't assign to any fields or call any other non-const methods.
Although, it does have this hideous const_cast<> operator that anyone can use to break these rules.