Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <QCoreApplication>
  2.  
  3. #include <QDebug>
  4. #include <QSharedDataPointer>
  5.  
  6. class CarData : public QSharedData
  7. {
  8. public:
  9.     int shit    = 1000;
  10.     int * shit2 = nullptr;
  11. };
  12.  
  13. class Car
  14. {
  15. public:
  16.     QSharedDataPointer<CarData> d;
  17. };
  18.  
  19.  
  20. int main(int argc, char *argv[])
  21. {
  22.     QCoreApplication a(argc, argv);
  23.  
  24.     QSharedDataPointer<CarData> carDataAAA = QSharedDataPointer<CarData>(new CarData());
  25.     QSharedDataPointer<CarData> carDataBBB = carDataAAA;
  26.  
  27.     Car car;
  28.     car.d = carDataBBB;
  29.  
  30.     Car * carPtr = &car;
  31.  
  32.     if( carPtr->d->shit == 1000 )
  33.     {
  34.         qDebug() << "bbb";
  35.     }
  36.  
  37.     if( !carPtr->d->shit2 )
  38.     {
  39.         qDebug() << "bbb";
  40.     }
  41.  
  42.  
  43.     return a.exec();
  44. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement