카테고리 없음
C++ 멤버 초기화 리스트
Chars4785
2018. 12. 18. 12:48
초기화 방법에는 여러가지가 있다.
1. 멤버 초기화
class Init{
public:
int value;
Init(int i): value(i){};
void OutValue(){ cout<< value;}
};
int main(){
int a = 3;
Init i(5);
i.OutValue();
cout<< endl;
return 0;
}
2. 레퍼런스 초기화