Stuck with this weird question
Why following code is OK for g++
#include <QObject>
class B {
public:
B(){}
~B(){}
};
class A : public QObject, public B {
Q_OBJECT
public:
A(QObject * parent = 0 ) : QObject( parent ), B() {}
~A(){}
};
int main(int argc, char *argv[])
{
A a1();
//A * a = new A();
//delete a;
return 0;
}
and this can not be compiled
/*... the same class definitions as above */
int main(int argc, char *argv[])
{
//A a1();
A * a = new A();
delete a;
return 0;
}
//error: undefined reference to `vtable for A'
I mean what to do to make the second good as well?
PS Well I put everything in separate files, and it works fine. So it is a matter of Q_OBJECT macros, I think.