У меня есть свой объект класса, если у меня есть этот объект в разных местах, и когда я удалил и инициализировал этот объект как NULL, я хочу, чтобы этот объект был NULL во всех других местах. Это возможно?
#include "mainwindow.h"
#include <QApplication>
#include "QDebug"
class A {
public:
int x;
int y;
};
class B : public A {
public:
B(int a, int b) {
this->m = a;
this->n = b;
}
int m;
int n;
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
B* temp = new B(1, 2);
B* b1 = temp;
B* b2 = temp;
delete temp;
temp = NULL;
qDebug() << b1->x << b2->x; //its print 421312312 -2131231231
return a.exec();
}