I have this:
//function definition
//Point and Range are classes made of 2 ints
Point barycenter_of_vector_in_range(vector<cv::Point> &points, cv::Range range);
//In other place...
vector<vector<Point> > tracks_; //it has some content
for (vector< vector<Point> >::const_iterator track = tracks_.begin(); track != tracks_.end(); track++) {
Point barycenter = barycenter_of_vector_in_range(&(*track), Range(0, track->size())); //Compile ERROR
}
I wonder why this is not working? I get “Invalid initialization of referenceof type …”
Any help would be very appreciated
Thanks
*trackis a reference toconst vector<Point>, so you have two problems:1) You’re trying to pass a pointer to that into
barycenter_of_vector_in_range, which doesn’t take a pointer.2) It’s
const, andbarycenter_of_vector_in_rangetakes a non-const reference.