Show a class Run using static data members that contains the following data members The name of the runner The distance covered by a runner The class has the following member functions Get function to input runner name and distance Show function to display runner name and distance
#include <iostream>
#include <string>
using namespace std;
class Run{
static string name;
static int distance;
public:
Run(){}
void Get(){
cout<<"Input name: ";
cin>>name;
cout<<"Input distance: ";
cin>>distance;
}
void Show(){
cout<<"Name: "<<name<<endl;
cout<<"Distance: "<<distance<<endl;
}
};
string Run::name = "";
int Run::distance = 0;
int main(){
Run runner;
runner.Get();
runner.Show();
return 0;
}
Comments
very helpfull!
Leave a comment