#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include<functional>
using namespace std;
class person
{
public:
explicit person(const int& a, const string& b) :age(a), name(b) { cout << "con cal" << endl; };
void test() {
cout << "1" << endl;
}
virtual void test1() {
cout << "2" << endl;
}
static void test2() {
cout << "3" << endl;
}
private:
int age;
string name;
};
int main()
{
person p1 = person(10, "woaini");
void(person:: * myptr)() = &person::test;
(p1.*myptr)();
void(person:: * myptr2)() = &person::test1;
(p1.*myptr2)();
void(*myptr3)() = &person::test2;
myptr3();
return 0;
}
c++ member function pointer
最新推荐文章于 2022-06-17 14:47:15 发布