default argument for template parameter for class enclosing

后端 未结 2 1304
终归单人心
终归单人心 2021-02-12 11:21

code:

template  >
class stack
{
    public:
        stack() {}
        temp         


        
2条回答
  •  自闭症患者
    2021-02-12 11:27

    That default parameter is, by syntax, a default parameter to the class, and it only makes sense at the class declaration.

    If you would call that function ...

    stack().empty();
    

    you only have the template parameters on the site of the class name, for which you already provided default parameters at the point of the template class declaration.

    You can solve the issue by simply removing the default parameter from the function definition:

    template
    bool stack::empty(){
        return container.empty();
    }
    

提交回复
热议问题