Answer to Question #215971 in C++ for Hamza ilyas

Question #215971

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


1
Expert's answer
2021-07-11T14:35:44-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

malaika
13.06.22, 20:44

very helpfull!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS