What is a non-trivial destructor in C++?

前端 未结 3 1590
情深已故
情深已故 2021-01-01 20:10

I was reading this which mentions destructors being trivial and non-trivial.

A class has a non-trivial destructor if it either has an explicitly def

3条回答
  •  一生所求
    2021-01-01 20:45

    I think in general it refers to a destructor that actually does something such as:

    • Release memory
    • Close a connection to database
    • Or take care of any resource that needs to be released

    In this case the destructor does nothing. According to the description, technically it may be 'non-trivial' because it defines a constructor, but it matters not, since it does nothing anyway.

提交回复
热议问题