이 튜토리얼에서는 C++의 사소한 클래스를 이해하는 프로그램에 대해 논의할 것입니다.
클래스/구조체 내부에 명시적으로 기본값이 포함되어 있는 경우 이를 Trivial 클래스라고 합니다. 더 간단한 클래스에는 자체 생성자, 할당 연산자 및 소멸자가 있습니다.
예시
//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.)