Object Deletion: use parent or not
- by metdos
Which one do you prefer to delete objects? Especially in QT, but other practices are also welcome. These two alternatives seem same to me, are they?
1.Bound to another class, and destroy when it is destroyed.
SomeClass::SomeClass{
socket_ = new QTcpSocket(this);
}
or
2.Destroy in the destructor of class
SomeClass::SomeClass{
socket_ = new QTcpSocket();
}
SomeClass::~SomeClass{
delete socket_;
}