| 
 
| #include <iostream> 
 using namespace std;
 
 class test
 {
 public:
 test(int a=0):val(a) {}
 typedef void (*F)(const int&);
 
 ~test(){dosomething(myprint);}//为什么非静态成员函数的指针不能作为参数
 void dosomething(F tmp)
 {//若此处给出默认参数如:void dosomething(F tmp=myprint),则myprint应是静态成员函数
 tmp(val);
 }
 private:
 int val;
 void myprint(const int& a){std::cout<<a<<std::endl;}//static
 
 };
 
 
 int main()
 {
 test c(8);
 return 0;
 }
 | 
 |