template class =默认类什么都不做?

use*_*152 3 c++ templates

我该如何工作?T=int当C++ 似乎完全无视它时,为什么让我写?

template<class T=int>
class Foo {
public:
    T a;
};

int main() {
    Foo f; //error: missing template arguments before ‘f’
}
Run Code Online (Sandbox Code Playgroud)

bil*_*llz 5

Foo 是一个模板,你还需要写:

Foo<> f;
// ^^
Run Code Online (Sandbox Code Playgroud)