:: *在C ++中是什么意思? [英] What does ::* mean in C++?

查看:69
本文介绍了:: *在C ++中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是什么

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

是平均值吗?

来自LAStools,位于 lasreader.hpp

It's from LAStools, in lasreader.hpp

BOOL typedef bool (来自

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.

推荐答案

这是指向成员函数的指针.具体来说, read_simple 是指向 LASreader 类的成员函数的指针,该成员函数接受零参数并返回 BOOL .

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.

来自cppreference中的示例:

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
}

这篇关于:: *在C ++中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆