"void value not ignored as it ought to be" - 夸脱/C++

"void value not ignored as it ought to be" - Qt/C++

本文关键字:be 夸脱 C++ to it value void not ignored as ought      更新时间:2023-10-16

我有这个简单的"界面"的一些插件,我想开发,它看起来像:

class TestPluginBase : public QObject
{
  Q_OBJECT
public:
    TestPluginBase();
    qint64 returnType(){return PluginType;}
protected:
    qint64 PluginType;
};

和其他一些实现"接口"的类,如:

class TestPluginONE : public TestPluginBase
{
public:
    TestPluginONE() {this->PluginType =1;}
    qint64 returnType() {return this->PluginType;}
};

然后我有另一个函数,假设加载不同的插件:

qint64 TestPluginManager::loadPlugin(QObject *_plugin)
{
  TestPluginBase *Plugin = qobject_cast<TestPluginBase *>(_plugin);
  if ( !Plugin )
        return 0;
    emit sigPluginLoaded(Plugin);
    return Plugin->returnType();
}

但是当构建它时,我得到void value not ignored as it ought to be和Qt创建者说从我正在做我的cast行实例化…不知道我做错了什么……

修改了我的"interface"中的构造函数为TestPluginBase() {this->PluginType =0;},代码正在编译,没有错误。解决了我的问题,但不知道为什么。