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);
}
June 11, 2021 Two interpretations | ||||
---|---|---|---|---|
| ||||
Is it specified somewhere which way the following program will be interpreted?
|
June 11, 2021 Re: Two interpretations | ||||
---|---|---|---|---|
| ||||
Posted in reply to JG | 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. |