小编hua*_*als的帖子

类封闭的模板参数的默认参数

码:

template <typename element_type, typename container_type = std::deque<element_type> >
class stack
{
    public:
        stack() {}
        template <typename CT>
        stack(CT temp) : container(temp.begin(), temp.end()) {}
        bool empty();
   private:
       container_type container;
};

template <typename element_type, typename container_type = std::deque<element_type> >
bool stack<element_type, container_type>::empty()
{
    return container.empty();
}
Run Code Online (Sandbox Code Playgroud)

当我编译它时会给出错误.

类封闭的模板参数的默认参数 'bool stack<element_type,container_type>::empty()'

为什么编译器会抱怨,我该如何使它工作?

c++ templates

19
推荐指数
1
解决办法
9317
查看次数

标签 统计

c++ ×1

templates ×1