[英]Multiple inheritance with QObject
I want to inherit QObject and another class and got an error: undefined reference for `vtable for EduGraph' I've read some threads about it and have fixed the sequence of the inherited classes in the class definition, but it haven't solved the problem. 我想继承QObject和另一个类,并得到一个错误:vtable for EduGraph的未定义引用我已经阅读了一些有关它的线程,并在类定义中修复了继承类的顺序,但尚未解决。问题。
class EduGraph : public QObject, public Graph<Vertex<ENode, EEdge>*> {
private:
std::list<Vertex<ENode, EEdge>*>::iterator firstSel;
std::list<Vertex<ENode, EEdge>*>::iterator secSel;
public:
Q_OBJECT
EduGraph() : firstSel(0), secSel(0) {}
~EduGraph();
void NewNode(const QPoint& p);
void RemoveNode();
void Associate();
void Dissociate();
signals:
void VertexSelected();
void VertexDeSelected();
};
`Undefined reference to `vtable for...'`
is usually a sign of unimplemented virtual function. 通常是虚拟功能未实现的标志。 Make sure you have implemented (defined) the corresponding virtual functions you inherited from the base classes .
确保已实现(定义) 从基类继承的相应虚函数 。
For example this will give you the same error because the print method in B is not implemented. 例如,这将给您同样的错误,因为未实现B中的打印方法。
class A {
public:
virtual void print() = 0;
};
class B : public A{
public:
void print();
};
int main()
{
B b;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.