EcLipSe-X said:
std::list said:
and write a function that takes this list as
argument, to find the middle node, and delete it from the list. The
function should return the new list. Is there anyone who can help?
Regards!
std::list<MyType> & MyFunc (std::list<MyType> & List)
{
// do stuff to List
return List;
}
Hint: to find middle node, use a for() loop and a
std::list<MyType>::iterator to iterator through the
list, and count nodes. Then start over at beginning,
iterator half the node count, erase the node.
The details are for the student to work out. Try
scrutinizing the "references", "standard containers",
and "iterators" chapters of your C++ book.
(Or, you could build your list from scratch using pointers,
malloc(), and free(); but that's the C way of doing it,
not the C++ way.)
--
Cheers,
Robbie Hatley
Tustin, CA, USA
email: lonewolfintj at pacbell dot net
web: home dot pacbell dot net slant earnur slant