이름공간
변수
행위

기본 초기화

cppreference.com
< cpp‎ | language

기본 초기화는 이니셜라이저 없이 변수가 생성될 때 수행됩니다.

목차

[편집] Syntax

T object ; (1)
new T ;

new T ( ) ; (until c++03)

(2)

[편집] Explanation

기본 초기화는 아래 세가지 상황에서 수행됩니다:

1) automatic, static, 또는 thread-local 저장소 기간인 변수가 이니셜라이저 없이 선언될 때;
2) 오브젝트가 이니셜라이저 없는 new-표현식을 통해 동적 저장소 기간으로 생성될 때또는 오브젝트가 빈 괄호쌍으로 이루어진 이니셜라이저를 가진 new-표현식 통해 생성될 때 (until C++03);
3) 기본 클래스나 non-static 데이터 멤버가 생성자 초기화 리스트에 없고, 해당 생성자가 호출될 때.

The effects of default initialization are:

  • if T is a non-POD (until C++11) class type, the constructors are considered and subjected to overload resolution against the empty argument list. The constructor selected (which is one of the