ns24.c

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

C
46
字号
#include "fail.h"

#ifdef __WATCOM_NAMESPACE__
struct V {
    void foo( char x );
};
struct D : virtual V {
    using V::foo;
    void foo( int );
};
struct E : virtual V {
};

V *pV;
D *pD;

struct F : virtual D, virtual E {
    F() {
	pV = this;
	pD = this;
    }
};

void V::foo( char x ) {
    if( x != '0' ) _fail;
    if( this != pV ) _fail;
}
void D::foo( int x ) {
    if( x != -2 ) _fail;
    if( this != pD ) _fail;
}

void foo( D *p ) {
    p->foo( -2 );
    p->foo( '0' );
}

int main() {
    F x;
    foo( &x );
    _PASS;
}
#else
ALWAYS_PASS
#endif

⌨️ 快捷键说明

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