티스토리 뷰
https://stackoverflow.com/questions/62252076/c-array-too-many-initializers
C++: array<> too many initializers
The following code is returning the compilation error below. I'm stuck understanding how there are too many initializers. This code works using vector<X>. Does anyone know why the error is...
stackoverflow.com
https://stackoverflow.com/questions/26629609/too-many-initializers-for-array-error
Too many initializers for Array error
I have implemented following structures: struct Point { int x,y; }; struct Array { Point elem[3]; }; Could you explain why I'm getting an error: error: too many initializers for 'Arr...
stackoverflow.com
std::pair 를 자료형으로 갖는 std::array 객체를 생성하려는데 초기화 과정에서 오류가 났다.
아래는 코드 예시인데 첫줄처럼 쓰려니 안되고 둘째줄 처럼 써야 됐다.
std::array<std::pair<int, int>, 4> dirs{ {1, 0}, {0, 1}, {-1, 0}, {0, -1} }; // error
std::array<std::pair<int, int>, 4> dirs{ { {1, 0}, {0, 1}, {-1, 0}, {0, -1} } }; // ok
괄호별로 아래와 같은 의미를 갖는다.
std::array<std::pair<int, int>, 4> dirs{ { {1, 0}, {0, 1}, {-1, 0}, {0, -1} } };
| | |
| | 초기화시 저장될 std::pair의 괄호를 의미
| 초기화시 저장될 std::pair 배열의 괄호를 의미
std::array class의 초기화를 알리는 괄호를 의미
'C++' 카테고리의 다른 글
[C++, ONNXRuntime] 20230731 Generic Programming, constexpr 을 맛본 날 (0) | 2023.07.31 |
---|---|
[C++] std::accumulate 가 0을 반환한다면... (0) | 2023.06.27 |
[C++] 컴파일러별 C++ 버전별 지원 기능 확인 (0) | 2023.01.23 |
[Modern C++, string, tolower] 문자열내 문자 소문자 변환 방법, 근데 이제 파이썬의 .lower() 같은 한줄 코드의 느낌을 곁들인 (0) | 2023.01.19 |
[C++] sizeof 는 알겠는데, sizeof... 는 뭐지? (0) | 2023.01.15 |
- Total
- Today
- Yesterday
- 문제집
- 이분탐색
- 자료구조
- Lowest Common Ancestor
- MOT
- 조합
- FairMOT
- 순열
- LCA
- 백준 11437
- 가장 긴 증가하는 부분 수열
- 백준
- ㅂ
- C++ Deploy
- 인공지능을 위한 선형대수
- 단축키
- 파이참
- 백준 1766
- cosine
- 백준 11053
- 백트래킹
- 위상 정렬 알고리즘
- PyCharm
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |