trivial default constructors

构造函数

A default constructor is trivial if it is not user-provided and if:

  • its class has ** no virtual functions **
  • and ** no virtual base classes **
  • and ** no non-static ** data member of its class has a brace-or-equal-initializer
  • and all the direct base classes of its class have ** trivial default constructors **
  • and for all the non-static data members of its class that are of class type (or array thereof),each such class has a trivial default constructor.

For a default constructor and destructor being "trivial" means literally ** "do nothing at all" **

If you define a constructor yourself, it is considered non-trivial, even if it doesn't do anything, so a trivial constructor must be implicitly defined by the compiler.

posted on 2021-06-01 19:06  Ultraman_X  阅读(57)  评论(0编辑  收藏  举报

导航