"void value not ignored as it ought to be" - 夸脱/C++
"void value not ignored as it ought to be" - Qt/C++
我有这个简单的"界面"的一些插件,我想开发,它看起来像:
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;}
,代码正在编译,没有错误。解决了我的问题,但不知道为什么。
相关文章:
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- 使用模板进行堆栈实现; "name followed by :: must be a class or namespace"
- 这对"With a stackless coroutine, only the top-level routine may be suspended."意味着什么
- 为什么我会" void value not ignored as it ought to be"?
- 如何解决"no Qt platform plugin could be initialized"问题?
- C++/SDL "initial value of reference to a non-const must be an lvalue"
- 如何修复输出日志中的"EnableInput can only be specified on a Pawn for its Controller"错误
- _BitScanForward64 can not be found
- C++复制函数重载导致"must be a nonstatic member function"错误
- 通过分隔符分隔包含 UTF-16 BE 文本的uint8_t数组
- C++ 错误:"array must be initialized with a brace-enclosed initializer"
- "expression must be a modifiable lvalue"是什么意思?
- 如何摆脱导入的 make 项目中的 Eclipse 索引器"Type std::... could not be resolved"错误
- Qt5 部署"procedure entry point could not be located"
- 为什么"types may not be defined in parameter types"
- SFINAE:"enable_if cannot be used to disable this declaration"
- 如何理解"abstract-declarator containing an ellipsis shall only be used in a parameter-declaration"
- 使用自定义 nodejs 插件时的"The specified module could not be found"
- "undefined class" 夸脱度/C++
- "void value not ignored as it ought to be" - 夸脱/C++