4
類
我得到以下編譯器錯誤名爲「VALUE_TYPE」:錯誤:沒有鍵入「
(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;
#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);
};
}
'std :: priority_queue'需要3個模板參數:值類型,序列類型和比較器。你似乎錯過了第二個。 – 2012-04-08 18:41:10
在第二個參數末尾是否有一個'>'丟失?或者這只是一個錯字? – alexisdm 2012-04-08 18:56:50
@alexisdm將代碼從vim移出到瀏覽器讓我更容易看到它。 – 2012-04-08 18:59:21