title: "指向成员函数的指针"
date: 2023-08-15T14:05:25+08:00
tags: ["C++"]
categories: []
draft: false
c++ - How do I typedef a function pointer with the C++11 using syntax? - Stack Overflow
#include <iostream>
class A {
public:
void display() { std::cout << "A display" << std::endl; }
};
int main() {
typedef void (A::*PF1)();
PF1 pf1 = &A::display;
A a1;
(a1.*pf1)();
using PF2 = void (A::*)();
PF2 pf2 = &A::display;
A* a2 = new A;
(a2->*pf2)();
return 0;
}
// output:
// A display
// A display
标签:函数,指向,08,C++,display,指针
From: https://www.cnblogs.com/devin1024/p/17631258.html