mp11.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 41 行
C
41 行
#include "fail.h"
struct B1 {
int b1;
};
struct B2 {
int b2;
};
struct D : B1, B2 {
int f1( D * );
int f2( D * );
};
typedef int (B1::* mp1)( void * );
typedef int (B2::* mp2)( void * );
void *t;
int launch1( B1 *p, mp1 mp ) {
return (p->*mp)( (void*)1 );
}
int launch2( B2 *p, mp2 mp ) {
return (p->*mp)( (void*)2 );
}
int D::f1( D *p ) {
if( this != t ) _fail;
return (int) p;
}
int D::f2( D *p ) {
if( this != t ) _fail;
return (int) p;
}
int main() {
D x;
t = &x;
if( launch1( &x, (mp1) &D::f1 ) != 1 ) _fail;
if( launch2( &x, (mp2) &D::f2 ) != 2 ) _fail;
_PASS;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?