C++ 模板参数:构造函数初始化

C++ 模板参数:构造函数初始化,c++,class,templates,template-templates,C++,Class,Templates,Template Templates,我正在尝试初始化: template DoubleLinkedList<Student>::DoubleLinkedList(typename Student<int> _data); //error: Explicit instantiation of 'DoubleLinkedList' does not refer to a function template... 模板DoubleLinkedList::DoubleLinkedList(typename学生数

我正在尝试初始化:

template DoubleLinkedList<Student>::DoubleLinkedList(typename Student<int> _data);
 //error: Explicit instantiation of 'DoubleLinkedList' does not refer to a function template...
模板DoubleLinkedList::DoubleLinkedList(typename学生数据);
//错误:“DoubleLinkedList”的显式实例化未引用函数模板。。。
构造代码为:

template <template <class> class T> DoubleLinkedList<T>::DoubleLinkedList(T<class _T> _data){
    head = NULL;
    curr = NULL;
    len  =    0;

    push(_data);
};  
模板双链接列表::双链接列表(T\U数据){
head=NULL;
curr=NULL;
len=0;
推送数据;
};  
试图传达以下信息的模板类:

template <template <class> class T> class DoubleLinkedList{};
template <class _T> class Student
模板类双链接列表{};
试图传达以下信息的模板:

template <template <class> class T> class DoubleLinkedList{};
template <class _T> class Student
模板类学生

向上

还有一个问题:我在课堂上有一个结构。我怎样才能求助于他?
curr=curr::_data->u name;//错误

您大概想要这个:

template <template <class> class T>
class DoubleLinkedList
{
    DoubleLinkedList(T<int> _data);

    // ...
};

template <template <class> class T>
DoubleLinkedList<T>::DoubleLinkedList(T<int> _data)
{
    head = NULL;
    // ...
    push(_data);
}
模板
类双链接列表
{
双链接列表(T_数据);
// ...
};
模板
DoubleLinkedList::DoubleLinkedList(T_数据)
{
head=NULL;
// ...
推送数据;
}
用法:

Student<int> s;
DoubleLinkedList<Student> x(s);
Student;
双链接列表x(s);
您大概想要这个:

template <template <class> class T>
class DoubleLinkedList
{
    DoubleLinkedList(T<int> _data);

    // ...
};

template <template <class> class T>
DoubleLinkedList<T>::DoubleLinkedList(T<int> _data)
{
    head = NULL;
    // ...
    push(_data);
}
模板
类双链接列表
{
双链接列表(T_数据);
// ...
};
模板
DoubleLinkedList::DoubleLinkedList(T_数据)
{
head=NULL;
// ...
推送数据;
}
用法:

Student<int> s;
DoubleLinkedList<Student> x(s);
Student;
双链接列表x(s);

I拆分header.cpp、main.cpp、constructor.cpp等,如果未初始化(在constructor.cpp中)则main看不到构造函数头:
template class Student{/..}
template class DoubleLinkedList{DoubleLinkedList(T_data);/}
constructor.cpp:
template DoubleLinkedList::DoubleLinkedList(T_data){/…}
模板双链接列表::双链接列表(学生数据);//-错误
I拆分header.cpp、main.cpp、constructor.cpp等,如果未初始化(在constructor.cpp中),则main未看到构造函数头:
模板类学生{/…}
模板类双链接列表{DoubleLinkedList(T_data);//…}
constructor.cpp:
template DoubleLinkedList::DoubleLinkedList(T_data){//…}
template DoubleLinkedList::DoubleLinkedList(Student_data);//-错误