guess what?

#include "stdio.h"
struct A{
    virtual ~A(){
        printf("ok");
    }
    virtual int f() = 0;
};

struct B: virtual public A{
    int f(){
        return 4;
    }
};


struct C: virtual public A{
    int f(){
        return 5;
    }
};


struct D : virtual  public B, virtual public C{
    ~D(){

    }
    int f(){
        return 6;
    }
};


struct E :virtual public B{

};

struct F : virtual public C{

};

struct G :  public E,  public F,  public D{
    int f(){
        return 9;
    }
};



int main(int argc, char *argv[])
{
    G g;
    D &a= *new D;
    B &b =a ;
    auto ll = sizeof (B);
    C &c = a;
    unsigned k=1;
    auto bb = k > -1;
    auto rb=b.f();
    auto rc = c.f();
    delete  &b;
    return 0;
}


posted @ 2020-06-29 16:20  zJanly  阅读(257)  评论(0编辑  收藏  举报