What does ::* mean in C++?

前端 未结 2 685
忘掉有多难
忘掉有多难 2021-02-04 07:42

What does

 private:
    BOOL (LASreader::*read_simple)();

mean?

It\'s from LAStools, in lasreader.hpp

BOOL is a

2条回答
  •  情歌与酒
    2021-02-04 08:07

    It's a pointer to member function. Specifically, read_simple is a pointer to a member function of class LASreader that takes zero arguments and returns a BOOL.

    From the example in the cppreference:

    struct C {
        void f(int n) { std::cout << n << '\n'; }
    };
    int main()
    {
        void (C::*p)(int) = &C::f; // p points at member f of class C
        C c;
        (c.*p)(1); // prints 1
        C* cptr = &c;
        (cptr->*p)(2); // prints 2
    }
    

提交回复
热议问题