模板模板参数:构造函数初始化
template template parameter: constructor initialization
我正在尝试初始化:
template DoubleLinkedList<Student>::DoubleLinkedList(typename Student<int> _data);
//error: Explicit instantiation of 'DoubleLinkedList' does not refer to a function template...
构造函数代码为:
template <template <class> class T> DoubleLinkedList<T>::DoubleLinkedList(T<class _T> _data){
head = NULL;
curr = NULL;
len = 0;
push(_data);
};
试图传达的模板class:
template <template <class> class T> class DoubleLinkedList{};
模板中试图传达的信息:
template <class _T> class Student
UP
还有一个问题:我在class中有一个结构class。我怎样才能求助于他?
curr = curr::_data->__name; // wrong
你大概想要这个:
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);
}
用法:
Student<int> s;
DoubleLinkedList<Student> x(s);
我正在尝试初始化:
template DoubleLinkedList<Student>::DoubleLinkedList(typename Student<int> _data);
//error: Explicit instantiation of 'DoubleLinkedList' does not refer to a function template...
构造函数代码为:
template <template <class> class T> DoubleLinkedList<T>::DoubleLinkedList(T<class _T> _data){
head = NULL;
curr = NULL;
len = 0;
push(_data);
};
试图传达的模板class:
template <template <class> class T> class DoubleLinkedList{};
模板中试图传达的信息:
template <class _T> class Student
UP
还有一个问题:我在class中有一个结构class。我怎样才能求助于他?
curr = curr::_data->__name; // wrong
你大概想要这个:
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);
}
用法:
Student<int> s;
DoubleLinkedList<Student> x(s);