2014-02-27 38 views
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,在这种情况下定义函数以外的类定义的正确语法是什么?

+0

相同的解决方法是对功能没有默认参数。 – chris

+1

你几乎肯定不希望它在'.cpp'文件中。 http://stackoverflow.com/questions/495021 –

+0

@MikeSeymour感谢指出..我认为我应该将实施移动到.h – sap

回答

0

写简单

template <typename T, typename A> 
void circular_dlist<T, A>::insert(T& val){ 
} 
+0

谢谢你的工作! – sap