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

前端 未结 3 1678
情深已故
情深已故 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条回答
  •  萌比男神i
    2021-01-01 21:02

    So you mean, the entire declaration of C is this:

    class C { };
    

    ?

    Then, yes: Since C has no member objects and no base classes, it therefore has no member objects with non-trivial destructors and no base classes with non-trivial destructors, so its implicitly-defined destructor is a trivial one.

提交回复
热议问题