182 Introduction to C++ Programming and Graphics
int main()
{
runner member[200]; // will hold up to 200 runners
runner fastest; // introduce the fastest runner
double fasttime = fastest.gettime(); // default time
bool more = true;
string answer;
int Ic = 0; // member counter
while (more)
{
Ic=Ic+1;
member[Ic].read(); // enter the next runner
member[Ic].print(); // print the properties of the next runner
if(member[Ic].gettime() < fasttime)
{
fastest = member[Ic];
fasttime = member[Ic].gettime();
}
cout << " More runners? (y/n)"; // inquire for additional runners
getline(cin, answer);
if(answer != "y") more = false;
}
int runners = Ic; // number of runners
cout << endl << " List of runners:" << endl;
cout << " ----------------" << endl;
for(int i=1;i<=runners;i++) member[i].print();
cout << endl << " Fastest runner:" << endl;
cout << " ---------------" << endl;
fastest.print(); // print the properties of the fastest runner
return 0;
}
Problems
6.12.1. What is the output of the following code?
E = runner();
cout<<E.getname()<<endl;