简体   繁体   English

在C ++中:: *意味着什么?

[英]What does ::* mean in C++?

What does 是什么

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

mean? 意思?

It's from LAStools, in lasreader.hpp 它来自LAStools,位于lasreader.hpp

BOOL is a typedef bool (from mydefs.hpp ), but I don't know what this line is declaring, specifically the ::* (double colon asterisk), and that it looks like a function call. BOOL是一个typedef bool (来自mydefs.hpp ),但我不知道这行是什么声明,特别是::* (双冒号星号),它看起来像一个函数调用。

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 . 具体来说, read_simple是一个指向类LASreader的成员函数的指针,它接受零参数并返回BOOL

From the example in the cppreference: 从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
}
BOOL (LASreader::*read_simple)();

read_simple是一个指向LASreader类的成员函数的LASreader ,它不带任何参数并返回BOOL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM