클래스에서 static const string 초기화

조회수 10819회

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";
}

1 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)