Theory question
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Thu May 21 16:13:47 PDT 2009
BCS wrote:
> Are there any cases where the following cases both compile but are not
> identical?
>
> A a;
> B b;
>
> a = b;
> a.Foo();
>
> //// and
>
> A a;
> B b;
>
> a = b;
> b.Foo();
struct A {
int i;
void Foo() { i = 42; }
}
alias A B;
The first case will set a.i to 42, the second will set b.i.
And with opAssign + different struct types they'd be calling two completely
different Foo()s.
Then there's array types + global function Foo(ref A), union types (similar to
struct types), class types + static Foo()s (different ones for A and B), ...
More information about the Digitalmars-d-learn
mailing list