3 필드의 배열 (크기가 count
)을 사용하고 싶습니다. 길이가 a
이고, 길이가 9 인 int 벡터는 b
이고 부울은 c
입니다.이 벡터를 올바르게 선언하는 방법?
신고 방법은 무엇입니까?
선언 1
vector <long a, vector<int> b(9), bool c> matrix(count);
오류 :
code.cpp: In function ‘int main()’:
code.cpp:89:49: error: template argument 1 is invalid
code.cpp:89:49: error: template argument 2 is invalid
code.cpp:89:57: error: invalid type in declaration before ‘(’ token
선언 2
vector <long, vector<int>, bool> matrix(count, a, vector<int> b(9), c);
오류 :
code.cpp: In function ‘int main()’:
code.cpp:90:40: error: wrong number of template arguments (3, should be 2)
/usr/include/c++/4.5/bits/stl_vector.h:170:11: error: provided for ‘template<class _Tp, class _Alloc> class std::vector’
code.cpp:90:48: error: invalid type in declaration before ‘(’ token
code.cpp:90:56: error: ‘a’ was not declared in this scope
code.cpp:90:71: error: expected primary-expression before ‘b’
code.cpp:90:77: error: ‘c’ was not declared in this scope
code.cpp:90:78: error: initializer expression list treated as compound expression
STL을 처음 접했고 여기에 올바른 구문이 무엇인지 모르십니까?
나는 무엇을 하려는지 명확하지 않지만 모든 객체에 3 개의 필드를 원한다면 구조체를 만들어야하고 그 3 개의 필드를 멤버로 가지고 다음 구조체의 객체를 벡터. –