I have a function

double Max(vector<geom_Point3> &Points, int n);

Then in another class, I have a private member:
vector<geom_Point3> Vertices_;

and in a class function, I call:
min_x = Min(Vertices_, 0);

however, I get

error: qualifiers dropped in binding reference of type "std::vector<geom_Point3, std::allocator<geom_Point3>> &" to initializer of type "const std::vector<geom_Point3, std::allocator<geom_Point3>>"
    min_x = Min(Vertices_, 0);

What does that mean??

Thanks!

Dave

Recommended Answers

All 6 Replies

well i fixed it by taking the & out of the Max() declaration....

but then isn't it passing the entire array (which is very big in this case) instead of just its address?


double Max(vector<geom_Point3> &Points, int n);

min_x = Min(Vertices_, 0);

Dave: Those are two different functions. Post the prototype for the Min() function, it apparently is different than for the Max() function which you posted.

>>but then isn't it passing the entire array (which is very big in this case) instead of just its address?
Yes its passing the entire array, which can be very time consuming for the program when the vector has a large amount of items.

Oh sorry, typo in the post. They should all be Min.

So why can't I put the & there?

The problem is something else. Possibly something that has not been declared. Try this -- it compiles ok for me with VC++ 2008 Express

struct geom_Point3
{
    int x,y;
};

double Min(vector<geom_Point3> &Points, int n)
{
    return 0.0;
}

int main()
{
    vector<geom_Point3> Vertices_;
    double min_x = Min(Vertices_, 0);
}

Man, right again - I wish it would give more informative errors sometimes...

> I have a function double Min(vector<geom_Point3> &Points, int n); > Then in another class, I have a private member:
> vector<geom_Point3> Vertices_; > and in a class function, I call: min_x = Min(Vertices_, 0); > however, I get error: qualifiers dropped in binding reference... > What does that mean??
> i fixed it by taking the & out of the Max() declaration...
> but then isn't it passing the entire array...
> So why can't I put the & there?

the qualifiers the compiler is mentioning are cv-qualifiers (const/volatile)
the class member function where you call min_x = Min(Vertices_, 0); is a const member function.

modify the function signature to make it const-correct double Min( const vector<geom_Point3>& Points, int n ) ; and you should be ok.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.