Properties: a.b.c = 3
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Jul 29 12:22:06 PDT 2009
Steven Schveighoffer wrote:
> On Wed, 29 Jul 2009 14:39:07 -0400, Ary Borenszweig
> <ary at esperanto.org.ar> wrote:
>
>> a.b.c = d;
>>
>> If b is anything that has a struct type, and c is anything else, the
>> statement must report an error.
>
> struct S
> {
> int *x;
> void c(int n) {*x = n;}
> }
>
> struct S2
> {
> int n;
> S b() { return S(&n);}
> }
>
> void main()
> {
> S2 a;
> a.b.c = 5;
> }
>
> Why should this not be allowed?
Simpler yet:
class C { int x; }
struct B { C c; }
struct A { C x; B b() { return B(x); }
void main()
{
A a;
a.x = new C;
a.b.c = 42; // fine, modifies the C object
}
Andrei
More information about the Digitalmars-d
mailing list