Which one do you prefer to delete objects? Especially in QT, but other methods are also welcome. These two alternatives seem the same to me, right?
Associated with another class and destroys when it is destroyed.
SomeClass::SomeClass{ socket_ = new QTcpSocket(this); }
or
Destroy in class destructor
SomeClass::SomeClass{ socket_ = new QTcpSocket(); } SomeClass::~SomeClass{ delete socket_; }
When in Rome do what the Romans do. If your framework uses one method (for example, Qt relies on the relationship between parents and children), use this method in your code.
, : , , ..
RAII , SomeClass. SomeClass QTcpSocket, . , , , delete this.
SomeClass
QTcpSocket
delete this
, , (1), , Qt ( ) .
Source: https://habr.com/ru/post/1743970/More articles:Отображение памяти файлов и поведение системного кэша в WinXP - cachingFreeRTOS queues for I / O before starting the scheduler (or after stopping it) - chttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1743967/how-do-we-redirect-all-requests-to-one-domain-to-a-section-of-another-domain&usg=ALkJrhh3n9NWjexuaRYDspMla1Ay6rnNPgВозврат вызова из объекта ggplot - rXAML dependency injection (WPF) - dependency-injection.Net MVC UserControl - RenderPartial or EditorFor - asp.net-mvcВозвращение нескольких объектов с использованием класса ASP.NET MVC JsonResult - classgetnameinfo points to socklen_t - cselect field information with minimum time value - phpWhy does inet_ntop () use socklen_t to describe the size of the text buffer? - cAll Articles