mp04.c

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

C
28
字号
#include "fail.h"
#include <stdio.h>


int expected;

struct S {
    void foo(int s) { if( expected != 1 || s != 1 ) fail(__LINE__); }
    void bar(int s) { if( expected != 0 || s != 0 ) fail(__LINE__); }
    static void _foo(int s) { if( expected != 1 || s != 1 ) fail(__LINE__); }
    static void _bar(int s) { if( expected != 0 || s != 0 ) fail(__LINE__); }
    void test(int s)
    {
	(this->*(s ? &S::foo : &S::bar))(s);
	( s ? _foo : _bar)(s);
    }
};

int main()
{
    S s;
    expected = 1;
    s.test(1);
    expected = 0;
    s.test(0);
    _PASS;
}

⌨️ 快捷键说明

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