본문 바로가기
카테고리 없음

C++ 멤버 초기화 리스트

by Chars4785 2018. 12. 18.

초기화 방법에는 여러가지가 있다. 


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. 레퍼런스 초기화



댓글