I'm trying to write a very simple program that makes use of QSharedDataPointer and QSharedData.

Here is my class:
Qt Code:
  1. #ifndef BUILDING_H
  2. #define BUILDING_H
  3.  
  4. #include <QSharedData>
  5. #include <QSharedDataPointer>
  6.  
  7. class BuildingPrivate;
  8.  
  9. class Building
  10. {
  11. public:
  12. Building();
  13. ~Building();
  14.  
  15. int value() const;
  16. void setValue(int value);
  17.  
  18. private:
  19. QSharedDataPointer<BuildingPrivate> d;
  20. };
  21.  
  22. #endif // BUILDING_H
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. #include "building.h"
  2.  
  3. class BuildingPrivate : public QSharedData {
  4. public:
  5. BuildingPrivate() {
  6. value = 0;
  7. }
  8. BuildingPrivate(const BuildingPrivate &other) {
  9. value = other.value;
  10. }
  11. ~BuildingPrivate() {}
  12.  
  13. int value;
  14. };
  15.  
  16. Building::Building()
  17. : d(new BuildingPrivate)
  18. {
  19. }
  20.  
  21. Building::~Building() { }
  22.  
  23. int Building::value() const
  24. {
  25. return d->value;
  26. }
  27.  
  28. void Building::setValue(int value)
  29. {
  30. d->value = value;
  31. }
To copy to clipboard, switch view to plain text mode 

And here is my main.cpp:
Qt Code:
  1. #include <QtCore/QCoreApplication>
  2. #include <QDebug>
  3.  
  4. #include "myobject.h"
  5.  
  6. Building build() {
  7. Building test;
  8. test.setValue(888);
  9. return test;
  10. }
  11.  
  12. int main(int argc, char *argv[])
  13. {
  14. QCoreApplication a(argc, argv);
  15.  
  16. qDebug() << build().value();
  17.  
  18. return 0;
  19. }
To copy to clipboard, switch view to plain text mode 

When I try to compile that I get:
Qt Code:
  1. In file included from /usr/include/qt4/QtCore/QSharedData:2,
  2. from building.h:5,
  3. from myobject.h:6,
  4. from main.cpp:5:
  5. /usr/include/qt4/QtCore/qshareddata.h: In copy constructor ‘QSharedDataPointer<T>::QSharedDataPointer(const QSharedDataPointer<T>&) [with T = BuildingPrivate]’:
  6. building.h:10: instantiated from here
  7. /usr/include/qt4/QtCore/qshareddata.h:90: error: invalid use of incomplete type ‘struct BuildingPrivate’
  8. building.h:7: error: forward declaration of ‘struct BuildingPrivate’
  9. /usr/include/qt4/QtCore/qshareddata.h: In destructor ‘QSharedDataPointer<T>::~QSharedDataPointer() [with T = BuildingPrivate]’:
  10. building.h:10: instantiated from here
  11. /usr/include/qt4/QtCore/qshareddata.h:87: error: invalid use of incomplete type ‘struct BuildingPrivate’
  12. building.h:7: error: forward declaration of ‘struct BuildingPrivate’
  13. /usr/include/qt4/QtCore/qshareddata.h:87: warning: possible problem detected in invocation of delete operator:
  14. /usr/include/qt4/QtCore/qshareddata.h:87: warning: invalid use of incomplete type ‘struct BuildingPrivate’
  15. building.h:7: warning: forward declaration of ‘struct BuildingPrivate’
  16. /usr/include/qt4/QtCore/qshareddata.h:87: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
  17. make: *** [main.o] Error 1
To copy to clipboard, switch view to plain text mode 


What am I missing?