struct and class member alias
Jarrett Billingsley
kb3ctd2 at yahoo.com
Wed Jun 6 05:00:32 PDT 2007
"Stuart Murray" <stuart.w.murray at fakey.nospambots.gmail.com> wrote in
message news:f458q0$2vea$1 at digitalmars.com...
>
> Interesting that it doesn't compile for you.. It definitely does for me
> (using DMD v1.014)
> This is the example I referred to, if anyones interested:
>
> class A
> {
> int foo(int x) { ... }
> int foo(long y) { ... }
> }
>
> class B : A
> {
> alias A.foo foo;
> override int foo(long x) { ... }
> }
>
> Its in the documentation. As I said, it's slightly different thing, but it
> seems to .. *match*..
Oh, well _that_ will compile :) It's because "A.foo" is not an expression,
it's a symbol. You're saying "bring my superclass's implementation of foo
into this namespace so it can be overloaded." A.foo is a name, so you can
alias it. The "A." is just there as a marker to say where foo lives.
In your example, pos and size are class instances; they have no meaning
until they've been new'ed. Furthermore, pos.x is not a symbol, it's an
expression -- it's an access to a member whose location can't be determined
at compile time. So, you can't alias it.
More information about the Digitalmars-d-learn
mailing list