Template trouble? :(

So at the moment I'm trying to implement a templated InList class to keep track of various data types, but I am terrible with templates. And I don't want to use STL as I am trying to do this as an exercise.

Here is what I have so far, with T1 my data-type and T2 an allocator if I want to specialize with an Allocator class.

//the InList class
template <typename T1, class T2 = NULL>
class InList
{
private:
struct Node {
T1* data;
Node* next;
Node* prev;
};

T2* _allocator; //if I create a memory manager, this will be used
Node* _head;
Node* _tail;

public:
//a constructor and destructor
InList();
~InList();
};

//somewhere far away in a driver...

InList<int> int_list;
InList<double> double_list;

I am getting a syntax error (C2059) '<constant tree>'.
Could someone tell me what this means and where I might be going wrong?
Thanks for the help!
closed account (3hM2Nwbp)
class T2 = NULL


Is NULL a type? I'm pretty sure it's a value.

You might be aiming for this?
 
template < class T, class T2 = allocator<T> > class InList;


*Edit3 http://www.cplusplus.com/reference/std/memory/allocator/
Last edited on
Yeah, thanks for that, that was my problem exactly :)

Passing NULL as a default template parameter == very bad. I fixed it by defaulting to my allocator class instead of NULL.
Topic archived. No new replies allowed.