Reputation: 1
I am trying to write an implementation of primms algorithm for a DSA class. There are some nuances to make the project a little trickier (some points cannot be reached by others based on the 'terrain' at that location) so I made a functor to get distances (edge weights). My functor looks like this
class primms_distance{
double operator ()(const primms_vertex &a, const primms_vertex &b){
//ommitted for University honor code purposes
}
};
However, I later do the following (again simplified for honor code purposes)
primms_vertex temp = priority_queue.top();
priority_queue.pop();
for(primms_vertex a : primms_vector){
if(omitted && primms_vertex::primms_distance(a, temp) < a.distance)
}
This call to primms distance gets me the error 'no matching constructor for initialization of 'primms_vertex::primms_distance'. Does anyone know why this is happening? The functor is clearly defined as 'double operator ()' so Im not sure why this is happening, any help would be appreciated!
Upvotes: 0
Views: 64
Reputation: 122585
You need an object to call a non-static member function. The compiler is right in expecting a call to the constructor first. Try this:
primms_vertex::primms_distance()(a, temp)
//^ constructor
// ^ operator()
Upvotes: 2