Passing member function pointer to member object in c++

后端 未结 4 1210
一个人的身影
一个人的身影 2020-12-04 22:54

I have a problem with using a pointer to function in C++. Here is my example:

#include 

using namespace std;

class bar
{
public:
    void (         


        
4条回答
  •  鱼传尺愫
    2020-12-04 23:08

    To make your second option work, declare foo so the compiler knows that it is a class.

    Also note that your function pointer syntax is incorrect. The * comes just before the name of the variable:

    class foo;
    
    class bar
    {
    public:
        void (foo::*funcP)();
    };
    

提交回复
热议问题