displaying info of object with iterator

Imgregorywong (20)
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 << " ";
Fransje (178)
You have to overload the << operator to achieve that: http://www.learncpp.com/cpp-tutorial/93-overloading-the-io-operators/
Registered users can post here. Sign in or register to post.