[SOLVED] Interface class - undefined reference to vtable for MyInterface
-
Hello everyone!
I'v been trying to create an interface class in my project. Based on this "example":http://doc.qt.nokia.com/4.6/tools-plugandpaint-interfaces-h.html I'v create following class:
@
#ifndef IVARIABLE_H
#define IVARIABLE_H#include <QtPlugin>
class QByteArray;
class QString;class IVariable{
public:
virtual ~IVariable(){}
virtual QString dataId() const;
virtual void setDataId(QString &dataId);
virtual QByteArray value() const;
virtual void setValue(QByteArray &value);
};
Q_DECLARE_INTERFACE(IVariable, "my.IVariable/1.0")
#endif // IVARIABLE_H
@
My problem is, that when i try to build my project where o got class Variable that implements such virtual class, I am getting following errors:
@
In function '~IVariable': variable.o
undefined reference to 'vtable for IVariable' ivariable.h 11
In function 'IVariable': variable.o
undefined reference to 'vtable for IVariable' ivariable.h 9
undefined reference to 'typeinfo for IVariable' (.rodata._ZTI8Variable[typeinfo for Variable]+0x18)
collect2:ld returned 1 exit status
@
I am quite new to C++ programing. Could anyone please explain me what am I doing wrong? Thanks a lot! -
If you define a real interface, the members must be pure virtual, which means, the yhave no implementation and that must be noted in the header:
@
class IVariable{
public:
virtual QString dataId() const = 0;
virtual void setDataId(QString &dataId) = 0;
virtual QByteArray value() const = 0;
virtual void setValue(QByteArray &value) = 0;
virtual void changeValue(QByteArray &value) = 0;
};
@