#ifndef A_H
#define A_H
#include <QtGlobal>
#include <QObject>
class A : public QObject
{
Q_OBJECT
public:
A(QObject* parent = NULL);
};
#endif // A_H
#include "a.h"
A::A(QObject* parent)
: QObject(parent)
{
}
#ifndef B_H
#define B_H
#include <QtGlobal>
#include <QObject>
#include "A.h"
class B : public A
{
Q_OBJECT
public:
B(QObject* parent = NULL);
};
#endif // B_H
#include "b.h"
B::B(QObject* parent)
: A(parent)
{
}
#include <cstdio>
#include <string>
#include <QtCore/QCoreApplication>
#include <QDebug>
#include "a.h"
#include "b.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QObject *obj = new B; // polymorphism in object-oriented programming
qDebug() << QString( obj->metaObject()->className() ); // print "B"
return 0;
}