クラス Stack の 2 つの異なる実装を作成したいと考えています。
(1)
template<typename element_type, typename container_type = std::vector<element_type> >
class Stack{//...
};
(2)
template<typename element_type, size_t container_size>
class Stack{
};
両方の実装を 1 つのファイルで定義すると、コンパイラ エラーが発生します。両方を同じファイルに入れることは可能ですか?
//compiler errors:
Stack.hpp:119:46: error: declaration of template ‘template<class element_type, long unsigned int container_size> int containers::Stack()’
Stack.hpp:25:9: error: conflicts with previous declaration ‘template<class element_type, class container_type> class containers::Stack’
Stack.hpp:25:9: error: previous non-function declaration ‘template<class element_type, class container_type> class containers::Stack’
Stack.hpp:119:46: error: conflicts with function declaration ‘template<class element_type, long unsigned int container_size> int containers::Stack()’