O'Reilly logo
  • LI WEI thinks this is interesting:

The constructor can be used for initialization of data fields and the destructor to call delete on any dynamically allocated resources (we haven't covered dynamically allocated resources yet, so don't worry about this last point yet).

From

Cover of Learning C++ by Creating Games with UE4

Note

怎么有效利用它们呢?在你需要初始化数据时,构造函数的内部是绝佳地方。当你的对象动态创建了一些对象时,在你的析构函数中将他们销毁