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