Overloading const member function

kenji hara k.hara.pg at gmail.com
Thu Jun 23 01:25:48 PDT 2011


2011/6/23 Daniel Gibson <metalcaedes at gmail.com>:
> how do you want to call the different A() functions? i.e. how will D
> know which one you want to call?

In member function S.min, member function A is called from implicit
'this' variable typed const(S).
So
>>     int min() const { return A() < b ? A() : b; }
is semantically analyzed to
int min() const { return this.A() < this.b ? this.A() : this.b; }
, then this.A() should be resolved overloads as int A() const.

Kenji


More information about the Digitalmars-d mailing list