공부/C, C++
-
[C++] struct형의 vector를 함수 인자로 넘기기공부/C, C++ 2021. 10. 8. 02:31
1. struct cand를 선언 2. cand형을 가지는 vector을 선언 (vector candidates;) 3. candidates를 정렬하기 위한 기준을 세워주는 compare 함수 정의 (bool cmp(vector &vec1, vector &vec2) 문제) cmp 함수에서 vec1의 멤버변수들이 참조가 되지 않음 해결) cmp 함수의 인자로 cand &vec1, cand &vec2를 넘겨주었더니 멤버변수들이 잘 참조되는 것을 확인함 구조체형 vector를 함수의 인자로 넘겨받고 싶을 때: 구조체 tag명 &vector 변수명