Two interpretations
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Jun 11 16:29:53 UTC 2021
On Fri, Jun 11, 2021 at 03:00:00PM +0000, JG via Digitalmars-d-learn wrote:
> Is it specified somewhere which way the following program will be
> interpreted?
>
> import std;
>
> struct A
> {
> int x=17;
> }
>
> int x(A a)
> {
> return 100*a.x;
> }
>
> void main()
> {
> A a;
> writeln(a.x);
> }
The rule is that member functions will always take precedence over UFCS.
UFCS only kicks in when the member function of that name cannot be
found.
T
--
For every argument for something, there is always an equal and opposite argument against it. Debates don't give answers, only wounded or inflated egos.
More information about the Digitalmars-d-learn
mailing list