language: C++11 (gcc-4.7.2)
date: 496 days 12 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#define CALL_MEMBER_FN(object,ptrToMember)  ((object).*(ptrToMember))
 
class Foo
{
 public:
  typedef void (Foo::*FFunc)( int i );
 
  void test( FFunc f )
  {
   CALL_MEMBER_FN(*this,f)( 123 );
  }
 
  void barf1( int i )
  {
   std::cout << " barf1" << std::endl;
  }
  ;
};
 
class Bar : public Foo
{
 public:
  void barf2( int i )
  {
   std::cout << " barf2" << std::endl;
  }
  ;
};
 
void ffff()
{
 Foo f;
 f.test( &Foo::barf1 ); // works
 
 Bar b;
 b.test( &Bar::barf1 ); // works
 b.test( ( Foo::FFunc )&Bar::barf2 ); // ERROR
}
 
int main( void )
{
 ffff();
 
 return ( 0 );
}