728x90 cpp static const 변수 c++98으로만 코드를 짜는 중에 발생한 오류! error: default member initializer for non-static data member is a C++11 extension [-Werror,-Wc++11-extensions] 클래스 안에서 변수 초기화는 c++11부터 지원해준다!😱 class A { private: int a = 0; } 이렇게 쓰는 것이 불가능!! c++98에서 static const 변수에는 클래스 안에서 초기화가 가능! 그렇다면 static const는 왜 클래스 안에서 초기화가 가능할까!? static 변수란? 객체들이 생성될 때마다 생성되는 것이 아닌, 클래스가 정의되기 이전(프로그램 시작과 끝까지)부터 메모리에 할당된 변수 = 클래스 변수(클래스 당 하나씩.. 2022. 1. 3. 이전 1 다음 728x90