#include #include #include #include #include #include #include #include #include #include class City { public: /** \brief adjacency list of this city */ std::vector Adj; /** \brief redecessor pointer */ City* p; /** \brief city value */ double d; /** \brief name of this city */ std::string name; /** \brief constructor with the city name as argument */ City(std::string name) { this->name=name; d=DBL_MAX; p=NULL; } /** \brief get (cost) value */ double getValue() const { return d; } }; struct CompareMethod { bool operator()(const City* a, const City* b) const { // Be sure to implement this function as "strictly less than" std::cout << "Ketchup!" << std::endl; return a->getValue() < b->getValue(); } }; void doStuff() { std::priority_queue, CompareMethod > Q; } laga@mbe:~/uni/alda/blatt10$ g++ dijkstra_route_template.cpp dijkstra_route_template.cpp: In function ‘void dijkstra(std::map, std::allocator >, City*, std::less, std::allocator > >, std::allocator, std::allocator >, City*> > >&, std::map, std::allocator >, std::map, std::allocator >, double, std::less, std::allocator > >, std::allocator, std::allocator >, double> > >, std::less, std::allocator > >, std::allocator, std::allocator >, std::map, std::allocator >, double, std::less, std::allocator > >, std::allocator, std::allocator >, double> > > > > >&, std::string)’: dijkstra_route_template.cpp:180: error: invalid initialization of reference of type ‘std::priority_queue >, std::less >&’ from expression of type ‘std::priority_queue > >, CompareMethod>’ dijkstra_route_template.cpp:133: error: in passing argument 1 of ‘City* getMinimum(std::priority_queue >, std::less >&)’ /usr/include/c++/4.3/bits/stl_queue.h: In constructor ‘std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = City*, _Sequence = std::queue > >, _Compare = CompareMethod]’: dijkstra_route_template.cpp:157: instantiated from here /usr/include/c++/4.3/bits/stl_queue.h:405: error: ‘class std::queue > >’ has no member named ‘begin’ /usr/include/c++/4.3/bits/stl_queue.h:405: error: ‘class std::queue > >’ has no member named ‘end’ /usr/include/c++/4.3/bits/stl_queue.h: In member function ‘void std::priority_queue<_Tp, _Sequence, _Compare>::push(const typename _Sequence::value_type&) [with _Tp = City*, _Sequence = std::queue > >, _Compare = CompareMethod]’: dijkstra_route_template.cpp:170: instantiated from here /usr/include/c++/4.3/bits/stl_queue.h:516: error: ‘class std::queue > >’ has no member named ‘push_back’ /usr/include/c++/4.3/bits/stl_queue.h:517: error: ‘class std::queue > >’ has no member named ‘begin’ /usr/include/c++/4.3/bits/stl_queue.h:517: error: ‘class std::queue > >’ has no member named ‘end’