0
我試圖讓一個類來定義圖搜索算法的行爲。C++製作一個類似容器的類
類接收到一個通用的容器作爲模板參數和行爲基於容器
template <typename N, typename E, class Container>
class Frontier {
private:
Container frontier;
public:
bool isEmpty() { return this.frontier.empty(); }
typename Graph<N, E>::const_iterator pop() { return this.frontier.pop(); }
bool push(typename Graph<N, E>::const_iterator it) { return this.frontier.push(it); }
};
上,但是當我嘗試編譯我得到
request for member ‘frontier’ in ‘this’, which is of non-class type
我知道這是因爲STL做容器是這樣實現的
template<class T, Class C = deque<T> > class std::stack;
我注意到大寫字母C在Class中所以我三編輯使用類的實現,但我從編譯器「類未定義」。我該如何解決這個問題?
可不敢相信我錯過了。我應該更新那個麻煩的編譯器,以便它能夠正確顯示錯誤消息(這實際上是整個錯誤消息,而我的gcc版本真的很舊。) –