#include
#include
class MyTest
{
public:
MyTest()
{
qDebug() << "MyTest ctor";
}
~MyTest()
{
qDebug() << "MyTest dector";
}
};
class Test
{
public:
Test(void* ptr)
: m_ptr(ptr)
{
qDebug() << "Test ctor";
}
~Test()
{
delete m_ptr;
qDebug() << "Test dector";
}
void* m_ptr;
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
{
MyTest *pTest = new MyTest();
Test test(pTest);
}
qDebug() << "Fin";
return a.exec();
}
// 运行结果:
MyTest ctor
Test ctor
Test dector
Fin
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)