VOOZH about

URL: https://www.geeksforgeeks.org/cpp/trivial-classes-c/

⇱ Trivial classes in C++ - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Trivial classes in C++

Last Updated : 8 Aug, 2017
When a class or struct in C++ has compiler-provided or explicitly defaulted special member functions, then it is a trivial type. It occupies a contiguous memory area. It can have members with different access specifiers. Trivial types have a trivial default constructor, trivial copy constructor, trivial copy assignment operator and trivial destructor. In each case, trivial means the constructor/ operator/ destructor is not user-provided and belongs to a class that has :
  • No virtual functions or virtual base classes,
  • No base classes with a corresponding non-trivial constructor/operator/destructor
  • No data members of class type with a corresponding non-trivial constructor/operator/destructor
The following examples show trivial types : Reference : https://learn.microsoft.com/en-us/previous-versions/mt767760(v=vs.140)?redirectedfrom=MSDN
Comment
Article Tags:
Article Tags: