- 论坛徽章:
- 0
|
我写了几行代码,想通过指向成员的指针,调用类当中的一个模板函数。
我在VC10下写的程序,
- #include"stdafx.h"
- struct s{
- void f(){printf("%s\n",__FUNCTION__);}
- template<class Pmf>
- void func{
- this->*Pmf();
- }
- };
- int main(void){
- s s1;
- s1.func(&s::f);
- return 0;
- }
复制代码 输出信息是:
1> my.cpp
1>c:\users\administrator\documents\visual studio 2010\projects\my\my\my.cpp(7): error C2182: 'func' : illegal use
of type 'void'
1>c:\users\administrator\documents\visual studio 2010\projects\my\my\my.cpp(4): error C3857: 's::func': multiple
template parameter lists are not allowed
1>c:\users\administrator\documents\visual studio 2010\projects\my\my\my.cpp(11): fatal error C1903: unable to
recover from previous error(s); stopping compilation
1>
程序错在哪里?
|
|