我收到以下编译器错误:
(graph_algorithms.h:59:111: error: no type named ‘value_type’ in ‘class Graph::graph_algorithms<int>::vertex_comparer’)
这是什么意思?
以下行给出了一大堆编译器错误
std::priority_queue<typename Graph::graph<U>::vertex, typename Graph::graph_algorithms<U>::vertex_comparer> pri_que;
Run Code Online (Sandbox Code Playgroud)
#ifndef GRAPH_ALGORIUHMS_H_
#define GRAPH_ALGORIUHMS_H_
#include <queue>
#include "graph.h"
namespace Graph
{
template <class U>
class graph_algorithms
{
// Forward declarations of
// internal classes
private :
class vertex_comparer;
public :
graph_algorithms(graph<U> &graph) :
m_Graph(graph)
{}
// List of algorithms to perform on graph
typename std::queue<U> &find_key_breadth_first(U key);
// Definition of internal classes
private :
class vertex_comparer
{
public:
bool operator()(typename graph<U>::vertex &v1, typename graph<U>::vertex &v2)
{
return (v1.key() < v2.key()) ? true : false;
}
};
private :
// Private member variables and methods
graph<U> &m_Graph;
std::queue<U> m_Queue;
void breadth_first_search(U key);
};
}
Run Code Online (Sandbox Code Playgroud)
比较类应该是std::priority_queue模板的第三个参数,第二个是一个包含成员的容器(如std::vector<typename Graph::graph<U>::vertex>)value_type。
| 归档时间: |
|
| 查看次数: |
13491 次 |
| 最近记录: |