<언어>/[C++]
[C++] Static
콜리브리
2022. 5. 2. 12:47
C++에선 static이 여러 의미를 가지고 있다.
Class 내부에서 static member를 지칭할땐 Java의 static과 같은 의미로 쓰이나,
Class definition 바깥에서 쓰일 땐 '이 함수/변수는 현재 파일 내부에서만 쓰인다' 라는 storage specifier로 쓰인다 (auto, register, static, extern 같은 keyword들)
https://en.cppreference.com/w/cpp/language/static#Static_data_members
static members - cppreference.com
Inside a class definition, the keyword static declares members that are not bound to class instances. Outside a class definition, it has a different meaning: see storage duration. [edit] Syntax A declaration for a static member is a member declaration whos
en.cppreference.com
초기화는 inline을 이용해서 definition과 동시에 initialize 하는게 이롭다 (C++17)