msc06.c

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 34 行

C
34
字号
/* should give only one error */
struct S {
protected:
    int s;
};
struct T : virtual S {
    int t;
    void foo();
};
struct R : virtual S {
    int r;
    void foo();
};
struct Q : R, T {
    int q;
};

Q *x;

void T::foo()
{
    x->s = 1;           /* OK (choose Q -> T -> S) */
}

void R::foo()
{
    x->s = 1;           /* OK (choose Q -> R -> S) */
}

void foo( void )
{
    x->s = 1;           /* BAD */
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?