c ++定义成员函数指针而不知道对象的类型

Dal*_*eme 4 c++ pointers

我知道标题不是很清楚,但我不知道如何用一句话写下来.所以问题是我想要这样的东西:

void(typeof(this)::*function)(int,int);
Run Code Online (Sandbox Code Playgroud)

我知道这不会起作用但是我在徘徊是否在c ++中存在这个问题的解决方案?

更新:

class MainPage
{
    public:
    MainPage()
    {
        void (std::remove_reference<decltype(*this)>::*callback)(int, int) = &MainPage::myFunction;
        ((*this).*callback)(nullptr,nullptr);
    }
    ~MainPage()
    {

    }

    void myFunction(int a, int b)
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

错误:

错误C2440:'newline':无法从'MainPage*'转换为'std :: remove_reference <_Ty>*'

错误C2647:'.*':无法在'MainPage'上取消引用'void(__thiscall std :: remove_reference <_Ty> ::*)(int,int)'

0x4*_*2D2 6

是的,使用decltype:

void (std::remove_reference<decltype(*this)>::type::*function)(int, int);
Run Code Online (Sandbox Code Playgroud)