Error with Template
Dec 11, 2013 at 1:53am UTC
I keep getting error C3857: 'ListNode::data': multiple template parameter lists are not allowed in VS2012. I am not quite sure what I am doing wrong. Can anyone help me understand what is happening?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#pragma once
class ListNode
{
public :
ListNode* nextPtr;
template <typename TYPE>
TYPE& data;
public :
template <typename TYPE>
ListNode(const TYPE& d, ListNode* n = 0)
{
this ->data = d;
this ->nextPtr = n;
}
ListNode();
};
Dec 11, 2013 at 2:06am UTC
1 2 3 4 5 6 7 8 9 10 11 12
#pragma one
template <typename TYPE>
class ListNode{
public :
ListNode* nextPtr;
TYPE& data; //¿a reference?
ListNode(const TYPE& d, ListNode* n = 0)
{
this ->data = d; //this doesn't make sense
this ->nextPtr = n;
}
};
Last edited on Dec 11, 2013 at 2:07am UTC
Dec 11, 2013 at 2:11am UTC
Its a reference to a class called Movie which holds a title and a rating. I'm using TYPE to be generic.
Topic archived. No new replies allowed.