displaying info of object with iterator

How do i get the iterator to display only for example the string name of an object ?


1
2
3
4
5
6
7
8
9
void Shop::display(Character& C)
{
	list <Item> temp = C.bag;
	list<Item>::iterator i;
	for( i = temp.begin(); i != temp.end(); ++i)
		cout<< *i << " ";
	cout << endl;

}

i have this at the moment but then i realize i didnt specify anywhere in the other part of the code what is to be displayed when the iterator is cout. how do i define what the iterator will display when i do this cout<< *i << " ";
You have to overload the << operator to achieve that: http://www.learncpp.com/cpp-tutorial/93-overloading-the-io-operators/
Topic archived. No new replies allowed.