passing vector to function c++

后端 未结 6 1036
借酒劲吻你
借酒劲吻你 2020-12-30 15:32

I have a main.cpp test.h and test.cpp> I am trying to pass my vector through so i can use it in test.cpp but i keep getting errors.

   //file: main.cpp
    i         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 15:50

    1. You should #include .
    2. string name should read std::string name etc. Same goes for std::vector.
    3. You're calling tester() with a vector, yet it expects an array (the two are not interchangeable).
    4. s.sizeof() is incorrect for both an array and a vector; for the latter, use s.size() or, better yet, use an iterator.

    These are just the errors that immediately jump out; there may be more.

提交回复
热议问题