I want to write two different implementations of class Stack.
(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{
};
If I define both the implementations in a single file I get compiler error. Is it possible to have both of them in the same file?
//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()’
You have to give them two different names if they take different kinds of parameters.