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.
Qt Code:
  1. incomehandler.h:21: error: ISO C++ forbids declaration of `QLabel' with no type
  2. 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?

Qt Code:
  1. #ifndef INCOMEHANDLER_H
  2. #define INCOMEHANDLER_H
  3.  
  4. #include <QDialog>
  5.  
  6. class QLabel; //With this row my prorgam compiles, without it i get the error posted above.
  7.  
  8. class IncomeHandler : public QDialog
  9. {
  10. Q_OBJECT
  11.  
  12. public:
  13. IncomeHandler(QWidget *parent = 0);
  14. signals:
  15.  
  16. private slots:
  17. void okClicked();
  18.  
  19. private:
  20. QLabel *activeLabel;
  21. QPushButton *okButton;
  22.  
  23. };
  24.  
  25. #endif
To copy to clipboard, switch view to plain text mode