Dear all,
As my title suggests, if I define the object vec1 by:
How can I define a pointer to vec1 and pass it to another function? Thanks a lot..Code:vector<double> vec1;
Dear all,
As my title suggests, if I define the object vec1 by:
How can I define a pointer to vec1 and pass it to another function? Thanks a lot..Code:vector<double> vec1;
May-be
void f(vector<double> &myVector) ?
and called:
f(vec1)
you can define the function with a reference argument.
then when you pass the vector object to a function, it will work on the copy. You can ensure it won't change by definint the function argument asCode:void foo(vector<T> &aVec) {//do something with the vector}
Code:void foo(const vector<T> &aVec)
I see. I was not sure whether I should add <.> thing in the function behind vector. Thanks a lot, pals.