-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
[아래질문 에러메시지]
20.01.24 07:21 작성 조회수 107
2
안녕하세요?
아래와 같이 에러메시지가 나옵니다.
기본 멤버 이니셜 라이저에서 배열 바운드를 추론 할 수 없습니다
========= 아래 ===============
검색해서 아래와 같은 정보를 찾았습니다.
여기에 아래와 같은 답변들을 보니까
Foo라는 구조체의 생성자의 멤버 이니셜라이제이션 리스트에서 초기화 될 수 있기 때문이라고 설명하는 거 같습니다.
because str
can be also initialized in the member-initialization-list of Foo's constructor, discarding the initializer from the in-class initializer
The reason is that you always have the possibility to override an in-class initializer list in the constructor. So I guess that in the end, it could be very confusing.
struct Foo
{
Foo() {} // str = "test\0";
// Implementing this is easier if I can clearly see how big `str` is,
Foo() : str({'a','b', 'c', 'd'}) {} // str = "abcd0"
const char str[] = "test";
};
Notice that replacing const char
with static constexpr char
works perfectly, and probably it is what you want anyway.
감사합니다.
답변을 작성해보세요.
0
답변 1