C++ 如何使用模板参数编写离线构造函数?

C++ 如何使用模板参数编写离线构造函数?,c++,templates,c++11,constructor,C++,Templates,C++11,Constructor,假设我有以下结构。我将如何为此编写越界构造函数 模板 结构foo { 模板 foo(int n,Bar); }; 您需要两个单独的模板声明: template <typename T> template <typename Bar> foo<T>::foo(int n, Bar bar) { // ... } 模板 模板 foo::foo(int n,Bar) { // ... }

假设我有以下结构。我将如何为此编写越界构造函数

模板
结构foo
{
模板
foo(int n,Bar);
};

您需要两个单独的模板声明:

template <typename T>
template <typename Bar>
foo<T>::foo(int n, Bar bar)
{
    // ...
}
模板
模板
foo::foo(int n,Bar)
{
// ...
}