default argument for template parameter for class enclosing

后端 未结 2 2091
清酒与你
清酒与你 2021-02-12 11:01

code:

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


        
2条回答
  •  不思量自难忘°
    2021-02-12 11:23

    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();
    }
    

提交回复
热议问题