On 21/03/10 00:18, bearophile wrote:
Robert Clipsham:
Why is this?
It's not a hard question. This code compiles:
class Foo {
const(Foo) myFoo() const {
return this;
}
}
void main() {
auto f = new Foo;
}
It's just in a const function the "this" is const, so if you want
Robert Clipsham:
> Why is this?
It's not a hard question. This code compiles:
class Foo {
const(Foo) myFoo() const {
return this;
}
}
void main() {
auto f = new Foo;
}
It's just in a const function the "this" is const, so if you want to return it,
then you have to use a "con
According to http://digitalmars.com/d/2.0/const3.html:
Const member functions are functions that are not allowed to change any
part of the object through the member function's this reference.
With the following code:
class Foo
{
Foo myFoo() const
{