Lab 9 - Template Classes

Due: 5:00pm on Wednesday

The purpose of this lab is to add a friend function to a template class.

Take the template_friends.cpp code discussed in class and copy it to your local directory as lab9.cpp. Add the input operator to the class. The prototype for the input operator is:

template <class T>
istream& operator >> (istream &, Testing<T>&);
Do not make Testing a const since the input operator has to write to it. For the body of the input operator, simply read from the input stream into the data member variable of Testing.

Replace main() with the following:

int main()
{
  Testing<int> tInt;
  Testing<double> tDouble;

  cout << "Enter an integer: ";
  cin >> tInt;

  cout << "Enter a double: ";
  cin >> tDouble;

  cout << "You entered the following: " << endl;
  cout << tInt << endl;
  cout << tDouble << endl;
  return 0;
}
Email your completed lab9.cpp to me.