Programming and Graphics

(Kiana) #1

180 Introduction to C++ Programming and Graphics


The implementation of theprintfunction is:


void runner::print() const
{
cout<<name<<" Country: "<<country<<" time: "<<endl;
}

The main function is allowed to make any of the following calls:



  • Define a default runner R:


runner R=runner();


  • Read the properties of runner A:


A.read();


  • Print the properties of runner A:


A.print();


  • Print the name of runner A and move to the next line:


cout<<A.getname() << endl;


  • Set and print the properties of runner B:


runner B = runner("Abdul", "Ethiopia", 9.00);
B.print();


  • Print the country and the performance time of runner B on different lines:


cout<<B.getcountry()<<endl;
cout<<B.gettime()<<endl;


  • Set the properties of runner C and print her time:


runner C("Dafela", "Ivory Coast", 9.40);
cout<<C.gettime()<< endl;


  • Introduce the default runner D and print his time:


D = runner();
cout<<D.gettime()<<endl;
Free download pdf