class A;
typedef void *(*func_ptr)(A*);  //C++的成员函数就是这么实现的

class A{
public:
        virtual A* get_p()
        {
                cout << "A::get_p()"<<endl;
                return this;
        };
};
int main()
{
        A a;
        
        int *v_p = (int *)&a;
        int *p = (int *)(*v_p);

        func_ptr pf = (func_ptr)(*(func_ptr*)p);

        pf(&a);
        return 0;
}

调用结果:

A::get_p()

 

说明,成功的调用了

 

 

 

posted on 2019-03-26 16:36  newbird2017  阅读(110)  评论(0编辑  收藏  举报