Calling a member function using function pointers from another class's instance

前端 未结 1 1910
有刺的猬
有刺的猬 2021-01-26 10:24
#include
#include
using namespace std;
class Base;
typedef void (Base::*function)();
class Base
{
public:
    function f;
    Base()
    {         


        
相关标签:
1条回答
  • 2021-01-26 10:50

    f doesn't appear to be in scope in Handler::CallFunction. I'm guessing you meant to call the b->f using b as this, as it (b->*(b->f))(). When I make this change, your code compiles and prints out something sane.

    0 讨论(0)
提交回复
热议问题