Template Linked List?

Hey, I've just finished implementing a Linked List. It works great with Integers. However, when I change it to String, it gives the following error:

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' (or there is no acceptable conversion)


1
2
3
4
5
6
7
8
9
template <class T>
void List<T>::print() {
	Node<T>* node = new Node<T>();

	for (node = head; node != NULL; node = node->next) {
		cout << node->value << " "; // Here's the error?
	}
	cout << endl;
}


EDIT: The Node and List definitions are as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
template <class T>
struct Node {
	T value;
	Node<T>* next;
};

template <class T>
class List {

private:
	Node<T>* head;
	Node<T>* curr;

public:
	List(void);
	void add(T value);
	void remove(T value);
	void print();
	~List(void);

};


Could you help me sort this out? As far as I am concerned, the left bitwise operator '<<' is overloaded for 'cout', why does it rise this error?

Thanks in advance.
Last edited on
did you include <string> ?

the relevant operator<< is defined in the <string> header.
Oh, how could I forget about that. Thanks! :)
Topic archived. No new replies allowed.