#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
class person
{
public:
person(string str):name(str) {}
int testName(){
cout<<"LINE:"<<__LINE__<<endl;
return !(name=="");
}
string getName(){
cout<<"LINE:"<<__LINE__<<endl;
return name;
}
string name;
private:
};
void out(person &one, string (person::*mem_fun)())
{
(one.*mem_fun)();
}
int main()
{
int(person::*pTestName)() = person::testName;
string(person::*pGetName)() = person::getName;
person *p_xiaohong = new person("xiaohong");
(p_xiaohong->*pTestName)();
(p_xiaohong->*pGetName)();
string person::*pPersonName = &person::name; //如果name是private的,会编译错误
cout<< p_xiaohong->*pPersonName << endl;
out(*p_xiaohong, person::getName);
out(*p_xiaohong, pGetName);
return 0;
}