I just started learning C++ today so I'm not familiar with whether I'm referencing the original vector or a copy. I'm trying to double the values of all the elements in my vector (go from 1, 2, 3 to 2, 4, 6) but the vector always prints the original values. Any tips are appreciated!
void doubleVector(vector<int> vec) {
for (int i = 0; i < vec.size(); ++i) {
vec[i] = vec[i] * 2;
}
}
int main() {
vector<int> vect{ 1, 2, 3 };
doubleVector(vect);
for (int x : vect) {
std::cout << x << ' ';
}
}