Template default arguments

前端 未结 4 1599
耶瑟儿~
耶瑟儿~ 2020-11-29 17:19

If I am allowed to do the following:

template 
class Foo{
};

Why am I not allowed to do the following in main?

4条回答
  •  臣服心动
    2020-11-29 17:50

    You have to do:

    Foo<> me;
    

    The template arguments must be present but you can leave them empty.

    Think of it like a function foo with a single default argument. The expression foo won't call it, but foo() will. The argument syntax must still be there. This is consistent with that.

提交回复
热议问题