এই টিউটোরিয়ালে, আমরা C++-এ ট্রিভিয়াল ক্লাস সম্পর্কে একটি প্রোগ্রাম আলোচনা করব।
যখন একটি ক্লাস/স্ট্রাক্ট এক্সপ্লিসিটলি ডিফল্টেড ভ্যালু ধারণ করে, তখন সেটিকে ট্রিভিয়াল ক্লাস বলা হয়। আরও ট্রিভিয়াল ক্লাসের নিজস্ব কনস্ট্রাক্টর, অ্যাসাইনমেন্ট অপারেটর এবং ডিস্ট্রাক্টর থাকে।
উদাহরণ
//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; };আউটপুট
(No output as we are just defining classes here and not creating object instances from them.)