 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Trivial classes in C++
In this tutorial, we will be discussing a program to understand trivial classes in C++.
When a class/ struct contains explicitly defaulted value inside it, then it is known as Trivial classes. Further trivial classes have their own constructor, assignment operator and destructor.
Example
//using the default constructor struct Trivial {    int i;    private:    int j; }; //defining your own constructor //and then marking it as default struct Trivial2 {    int i;    Trivial2(int a, int b){       i = a;    }    Trivial2() = default; };  Output
(No output as we are just defining classes here and not creating object instances from them.)
Advertisements
 