New to templates and lists but i have to use them for a class project. I got it working in one file then i tried to make it a class and I keep getting this error:

1>c:\users\r4ck13y\programming\c++ projects\project2.1\project2.1\merginglists.h(11) : error C2955: 'std::list' : use of class template requires template argument list
1> c:\program files\microsoft visual studio 9.0\vc\include\list(95) : see declaration of 'std::list'

Here is the header file that im about 90% sure the error is coming from. Please help. Thank you.

#include "stdafx.h"
#include <list>
#include <iostream>
using namespace std;
class MergingLists : public list
	template <typename T>	void splitlist(list<T> L, list<T>& first, list<T>& second);
	template <typename T>	list<T> merge(list<T>& first, list<T>& second);
	template <typename T>	list<T> mergesort(list<T>& L);

Edited by __avd: Added [code] tags.

8 Years
Discussion Span
Last Post by firstPerson

You know most of the time the error says it all :

::list' : use of class template requires template argument list

You have this

class MergingLists : public list

The error tells you that list uses templates so that means that
your MergingLists has to also be a template class if you want
to inherit from list.

So you can either change your code to this

template<typename Type>
class MergingLists : public list<Type>

Or you can just inherit one type like so :

typedef int Type;
class MergingLists : public list<Type>{}

For the second one you can only have 1 Type, so Type can either be
int,string,float, or double, but not all; Whereas the first one can be

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.