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

时间:2017-02-21 18:34:45

标签: 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...

构造函数代码是:

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

    push(_data);
};  

尝试传达的模板类:

template <template <class> class T> class DoubleLinkedList{};

尝试传达的模板:

template <class _T> class Student

UP

还有一个问题:我在课堂上有一个结构。我怎么能转向他呢? curr = curr::_data->__name; // wrong

1 个答案:

答案 0 :(得分:2)

你大概想要这个:

this.$timeout(3000,true).then(() => {});

用法:

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);
}