클래스에서 static const string 초기화
조회수 10540회
static const
멤버 변수는 클래스 안에서 초기화 해도 되는 거 아닌가요?
에러메세지에서는 out of line에서 초기화하라네요.
#define
은 안 쓰고 싶은데 어떡하면 되나요
에러메세지
Static data member of type 'const string' (aka 'const basic_string<char, char_traits<char>, allocator<char> >') must be initialized out of line member
소스코드
class A {
private:
static const string RECTANGLE = "rectangle";
}
댓글 입력