October 28, 2005 typedef members inaccessible | ||||
---|---|---|---|---|
| ||||
struct Foo { void stuff() { } } typedef Foo Bar; int main() { Bar b; b.stuff(); // here return 0; } DMD 0.137 output: test.d(9): this for stuff needs to be type Foo not type Bar Was this intended? If so, what is the reason? Shouldn't the type implicitly convert to its base to find the member? |
October 28, 2005 Re: typedef members inaccessible | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vathix | On Fri, 28 Oct 2005 02:31:25 -0400, Vathix wrote: > struct Foo > { > void stuff() { } > } > typedef Foo Bar; > int main() > { > Bar b; > b.stuff(); // here > return 0; > } > > DMD 0.137 output: > test.d(9): this for stuff needs to be type Foo not type Bar > > Was this intended? If so, what is the reason? Shouldn't the type implicitly convert to its base to find the member? I must admit that this looks odd ... struct Foo { void stuff() { } } typedef Foo Bar; int main() { Bar b; (cast(Foo)b).stuff(); // now it works. return 0; } Also, instead of typedef, alias makes it compile, but I guess that's not your point. -- Derek (skype: derek.j.parnell) Melbourne, Australia 28/10/2005 4:51:21 PM |
Copyright © 1999-2021 by the D Language Foundation