I have a std::vector<vector<double>>
I want to fill in one function.
I need to store some 3 dimensional coordinates for some calculations later in my program.
My Question is if I do this:
//in classdefinition
std::vector<std::vector<double>> data;
myFunc()
{
std::vector<double> temp;
temp.push_back(1);
temp.push_back(2);
temp.push_back(3);
data.push_back(temp);
temp.clear();
//new data
temp.push_back(2);
temp.push_back(3);
temp.push_back(4);
data.push_back(temp);
}
will the clearing and refilling of temp influence the values in data?
I already found this http://www.cplusplus.com/reference/vector/vector/push_back/ but since the explanation reads "The content of val is copied (or moved) to the new element." I don't know what to think. To me this sounds like a contradiction.
I think it would not make much sense if the variables are passed as a reference since they can, like in my case, only be valid in a limited scope. Am I right with my assumption?