What does ::* mean in C++?

前端 未结 2 688
忘掉有多难
忘掉有多难 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
    }
    
    0 讨论(0)
  • 2021-02-04 08:20
    BOOL (LASreader::*read_simple)();
    

    read_simple is a pointer to a member function of class LASreader that takes no arguments and returns a BOOL.

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