I am getting a strange c++ error:
main.cpp:81:9: error: request for member ‘push_back’ in ‘points’, which is of non-class type ‘std::vector<std::vector<float> >()’
I am reading this like c++ is trying to tell me that the function push_back
is not part of the vector class. Here is my relevant code:
vector<vector<float> > points(); //construct an empy vector of vectors
vector<float> first(3,0); //construct 0 vector in R^3
points.push_back(first); //put (0, 0, 0) in points
All help is greatly appreciated!
This is a case of MVP (Most Vexing Parse):
vector<vector<float> > points();
This is actually a function declaration, change it to:
vector<vector<float> > points;
With the first version, C++ thinks you're declaring a function called points which takes no arguments and returns a vector of vector of floats. That's why it's complaining about it being a non-class type.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.