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.
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.
class A {
public:
virtual void print() = 0;
};
class B : public A{
public:
void print();
};
int main()
{
B b;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.