I am new to C++ and trying to understand how arguments are passed to functions, particular with regards to objects such as the std::vector.
When a variable is passed as an argument to a function, a copy of the variable is made, and the copy is passed to the function, right? For this reason, if we are passing a large object to a function, it is wise to pass a pointer to the object, rather than the object itself, to speed things up.
However, what happens when a std::vector is passed as an argument?
Suppose the we have a vector of objects of type MyClass, such as vector<MyClass> my_vector, and we pass this as an argument to a function. Will the entire vector be copied, such that every instance of MyClass stored in the vector is also copied? This would take a long time right?
But if we have a vector of pointers, such as vector<MyClass*> my_vector, then when the vector is passed as an argument, are the actual objects themselves copied, or is a copy only made of the pointers to those objects?
Is there any way we can pass a vector as an argument, without having to make all these copies, as this is very time consuming??