C++ 中的平凡类
本教程中,我们讨论一个程序来了解 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.)
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP