title: expected class-name before '{' token
body: <p>I'm getting the error "expected class-name before '{' token" in my C++ Qt project. After googling it, it seems like its a problem of circular includes. I have pawn.h that includes piece.h, which includes board.h, which completes the circle by including pawn.h. I've read that this can be fixed with forward declarations, but I've tried forward declaring a few of problem classes, and it doesn't work.</p>
  
  <pre><code>#ifndef PAWN_H
  #define PAWN_H
  
  #include "piece.h"
  
  class Pawn : public Piece
  {
      Q_OBJECT
  public:
      explicit Pawn(QWidget *parent = 0);
  };
  
  #endif // PAWN_H
  </code></pre>
  
  <p>.</p>
  
  <pre><code>#ifndef PIECE_H
  #define PIECE_H
  
  #include &lt;QWidget&gt;
  #include "board.h"
  
  class Board;
  class Piece : public QWidget
  {
      Q_OBJECT
  public:
      explicit Piece(QWidget *parent = 0);
      void setPosition(int rank, int file);
      QPixmap pixmap;
  
  protected:
      void paintEvent(QPaintEvent *);
  
  private:
      int rank;
      int file;
      int x;
      int y;
  };
  
  #endif // PIECE_H
  </code></pre>
  
  <p>.</p>
  
  <pre><code>#ifndef BOARD_H
  #define BOARD_H
  
  #include &lt;QWidget&gt;
  #include &lt;QVector&gt;
  #include &lt;QGridLayout&gt;
  #include "square.h"
  #include "pawn.h"
  #include "knight.h"
  #include "bishop.h"
  #include "queen.h"
  #include "king.h"
  
  class Board : public QWidget
  {
  public:
      explicit Board(QWidget *parent = 0);
      QVector &lt; QVector&lt;Square *&gt; &gt; sqrVector;
      Pawn *pawn[8];
  
      Knight *knight[2];
  
      Bishop *bishop[2];
  
      Queen *queen;
      King *king;
  
  private:
      QGridLayout *layout;
  };
  
  #endif // BOARD_H
  </code></pre>