I\'m coding in C++. If I have some function void foo(vector and I call it in my program, will the vector be passed by value or reference? I\'m
void foo(vector
vector would be passed by value in this.
You have more ways to pass vectors depending on the context:-
1) Pass by reference:- This will let function foo change your contents of the vector. More efficient than pass by value as copying of vector is avoided.
2) Pass by const-reference:- This is efficient as well as reliable when you don't want function to change the contents of the vector.