diag0177.c

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

C
29
字号
// non-static member function cannot be used as operand of ":"

  void nonmemb( char* s );


  struct S {
   void foo(char* s);
   void bar(char* s);

   static void (S::*mf)( char* );

   void test( int j )
   {
    mf = j ? &S::foo : &S::bar;
    mf = & (j ? S::foo : S::bar );
    (j ? nonmemb : bar)("test"); 
    (j ? foo : nonmemb)("test"); 
    (j ? nonmemb : nonmemb)("test");
    (j ? foo : bar)("test");
   }
  };

  void main()
  {
   S s;
   s.test( 1 );
   s.test( 0 );
  }

⌨️ 快捷键说明

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