0
我想作爲C++定製容器編譯錯誤
template <typename T, typename A = std::allocator<T> >
class circular_dlist{
....
public:
class iterator{
....
};
void insert(T& val);
};
在.cpp文件時,我定義插入寫一個容器()方法:
template <typename T, typename A = std::allocator<T> >
void circular_dlist<T, A>::insert(T& val){
}
我獲得以下錯誤:
error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11
如果我不使用C++ 11,在這種情況下定義函數以外的類定義的正確語法是什麼?
相同的解決方法是對功能沒有默認參數。 – chris
你幾乎肯定不希望它在'.cpp'文件中。 http://stackoverflow.com/questions/495021 –
@MikeSeymour感謝指出..我認爲我應該將實施移動到.h – sap