//File:	link_driver.cpp
#include "linked.h"
#include <iostream>
#include <string>
using namespace std;

template <class T>
T average(const myList<T> & L)
{
	T number, sum=0;
	int k=0;
	ListIterator<T> i(L);
	while (i.next(number))
	{
		sum += number;
		k++;
	}
	
	return sum/k;
}

int main()
{
	myList<string> L;
	
	L.add_front("Bill");
	L.add_front("Mohamed");
	L.add_rear("George");
//	L.remove_front();
//	L.remove_rear();

	cout <<L << endl;
	
//The following averaging code requires access to the list private field, front
/*	int sum=0, k=0;
	
	for (node * temp=L.front; temp != NULL; temp=temp->next)
	{
		sum += temp->data;
		k++;
	}
*/


//The ListIterator class comes to the rescue

//	cout << "Average=" << average(L) << endl;

	return 0;
}
