강의

멘토링

커뮤니티

Inflearn Community Q&A

pokor21074's profile image
pokor21074

asked

Following and Learning C++ with Hong Jeong-mo

8.10 Static Member Variables

Static이 클래스 내에서 초기화 되지 않는 이유가 뭔가요?

Written on

·

327

2

C#에서은 클래스 내부에서 static 사용시 초기화가 가능한데 C++은 초기화가 되지 않도록 막은 이유가 있을까요?

C++

Answer 1

3

C++ 에서는 클래스 내부에 static member variable을 만들면 선언의 의미로만 사용됩니다. (Stroustrup, The C++ Programming Language, 4th ed. pp 506.)
const 로 선언하면 클래스 내에서 초기화도 가능합니다.
이렇게 만든 이유에 대해선 특별히 언급하지 않네요.

pokor21074's profile image
pokor21074

asked

Ask a question