Hello.
This is a question to still my curiosity about forward declarations. According to Blanchette and Summerfield's book, forward declarations is needed only to make compilation "somewhat faster". But I just got problems for not having them onboard in my program.
incomehandler.
h:21: error
: ISO C
++ forbids declaration of `
QLabel' with no typeincomehandler.h:21: error: expected `;' before '*' token
incomehandler.h:21: error: ISO C++ forbids declaration of `QLabel' with no type
incomehandler.h:21: error: expected `;' before '*' token
To copy to clipboard, switch view to plain text mode
I commented after the declaration in question in the code below, and since the compiler doesn't go on strike now even if I still haven't forward-declared the QPushButton.
Why is The QLabel more sensitive than QPushButton?
#ifndef INCOMEHANDLER_H
#define INCOMEHANDLER_H
#include <QDialog>
class
QLabel;
//With this row my prorgam compiles, without it i get the error posted above.
class IncomeHandler
: public QDialog{
Q_OBJECT
public:
IncomeHandler
(QWidget *parent
= 0);
signals:
private slots:
void okClicked();
private:
};
#endif
#ifndef INCOMEHANDLER_H
#define INCOMEHANDLER_H
#include <QDialog>
class QLabel; //With this row my prorgam compiles, without it i get the error posted above.
class IncomeHandler : public QDialog
{
Q_OBJECT
public:
IncomeHandler(QWidget *parent = 0);
signals:
private slots:
void okClicked();
private:
QLabel *activeLabel;
QPushButton *okButton;
};
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks