2012年(158)
分类: C/C++
2012-11-20 11:24:24
#include
using namespace std;
struct A {
static void (A::*pfn)();
void foo(){ cout <<
"a" << endl; }
};
void (A::*pfn)()=&A::foo;
int main() {
pfn; // it's right, becasue pfn is a
global variant
A a;
(a.*pfn)();
}
//////////////////////////////////////////////////////////////////////////////////
#include
using namespace std;
struct A {
static void (A::*pfn)();
void foo(){ cout <<
"a" << endl; }
};
void (A::*A::pfn)()=&A::foo;
int main() {
// pfn; // it's wrong, becasue pfn is
a member variant of A
A a;
(a.*A::pfn)();
}