tags:

views:

186

answers:

3

I am reading through the examples on the Qt page and am wondering why they add references to already existing classes in their code example:

#ifndef HTTPWINDOW_H
#define HTTPWINDOW_H

#include <QDialog>

class QFile;
class QHttp;
class QHttpResponseHeader;
class QLabel;
class QLineEdit;
class QProgressDialog;
class QPushButton;

class HttpWindow : public QDialog
{
...
+8  A: 

Those are forward declarations. Using them can (in some cases) obviate the need to #include the relevant header files, thus speeding up compilation. The Standard C++ library does something similar with the <iosfwd> header.

anon
+8  A: 

This is called Forward Declaration

You can refer to this question here to have a detailed idea of when to use Forward Declaration

Aamir
+1  A: 

As mentioned above, this is simply a forward declaration. And in the header file these classes will typically be used via pointers so a full declaration of the class is not needed until the .cpp. So, e.g. your header might continue...

class HttpWindow : public QDialog
{

QFile *m_pFile;
QHttp *m_pHttp;
...
}