int main () {
vector <int> vectorF;
functionX <vector<int>&, long> (vectorF, 1L);
}
template <typename dataTypeA,
typename dataTypeB> dataTypeB functionX (dataTypeA argA,
dataTypeB argB)
{
}
This code changes the actual values in the vector, if modified in the function definition.
What is the way to pass the vector by copy?
functionX <vector<int>, long> (vectorF, 1L);Addind a
&after thevector<int>will make thedataTypeAto be a reference to a vector. If you want a copy to a vector, remove the &