I am new to C++. Say I have the following code:
vector<int> vec;
vec.push_back(5);
int x = vec.at(0);
From my understanding, x
now represents a reference to the value in the vector. If this is the case, then why is it that if I were to have x = 7
, the value in the vector would still be 5?
I tried searching on the site for a relevant thread, but did not see any that answered the question.