爲什麼GCC不允許默認參數?爲什麼C++不允許這個默認值?
template<class edgeDecor, class vertexDecor, bool dir>
Graph<edgeDecor,int,dir> Graph<edgeDecor,vertexDecor,dir>::Dijkstra(vertex s, bool print = false) const
{
這是輸出我得到:
graph.h:82: error: default argument given for parameter 2 of ‘Graph<edgeDecor, int, dir> Graph<edgeDecor, vertexDecor, dir>::Dijkstra(Vertex<edgeDecor, vertexDecor, dir>, bool)’
graph.h:36: error: after previous specification in ‘Graph<edgeDecor, int, dir> Graph<edgeDecor, vertexDecor, dir>::Dijkstra(Vertex<edgeDecor, vertexDecor, dir>, bool)’
任何人都可以明白爲什麼我得到這個?
我看不出爲什麼你得到這個,因爲你只包括相關代碼的一部分。你的錯誤同時涉及第36行和第82行,所以你需要在問題中包括這兩個。 – 2010-03-23 00:35:59
對不起布魯克斯,好點。第36行是我班的函數原型。 – 2010-03-23 04:35:09