d的betterC`有一个`,来替换`是一个`的继承

使外(c++)在-betterC中有效地址

struct Base
{
    int x;
    void g(){
        import core.stdc.stdio;
        printf("%d",x);
    }
}

struct Derived
{//有一个来实现继承
    Base _base;
    alias _base this;
}

void foo(Base b)
{
    b.g();
}

extern(C)void main(){//Symbol Undefined __d_run_main
    //没有extern(C)就会出现上面的问题
    Derived d;
    d.x = 42;
    foo(d);
}

地址在此

posted @ 2020-02-19 17:53  zjh6  阅读(18)  评论(0)    收藏  举报  来源