【问题标题】:error: request for member ‘update’ in ‘ofEvents’, which is of non-class type ‘ofCoreEvents&()’|错误:在“ofEvents”中请求成员“更新”,它是非类类型“ofCoreEvents&()”|
【发布时间】:2013-10-30 19:56:23
【问题描述】:

我有一个使用 OpenFrameWorks 007 预发行版编写的 C++ 代码,我正在对其进行修改以匹配 OpenFrameWorks 008。行 -

1. ofAddListener(ofEvents.update, this, &ofxAutoControlPanel::update); 给出错误 - src/ofxAutoControlPanel.h|9|error: request for member ‘update’ in ‘ofEvents’, which is of non-class type ‘ofCoreEvents&()

我无法破译。

  1. 将ofEvents.update 更改为ofEvents->update 会引发同样的错误
  2. 将ofEvents.update 更改为ofEvents().update 即可解决问题

谁能解释这三种情况的区别?

【问题讨论】:

    标签: c++ class member openframeworks


    【解决方案1】:

    似乎 ofEvents 是指向一个具有 ofCoreEvents&() 类型的函数的指针。即函数调用返回对具有数据成员更新的CoreEvents 类型对象的引用。

    【讨论】:

      【解决方案2】:

      这是因为 ofEvents 类已在 OF 0071 中更改。 引用自changelog:

      ofEvents -> ofEvents() 单例 - 这意味着使用“ofEvents”注册调用的项目。将需要用“ofEvents()”替换这些。 (注意括号)。

      这就是你的第二个解决方案有效的原因。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-27
        相关资源
        最近更新 更多