Example
Example
#include <iostream>
using namespace std;
class RunnerInfo {
public:
void SetTime(int timeRunSecs);
void SetDist(double distRunMiles);
double GetSpeedMph() const;
private:
int timeRun;
double distRun;
};
void RunnerInfo::SetTime(int timeRunSecs) {
timeRun = timeRunSecs;
return;
}
void RunnerInfo::SetDist(double distRunMiles) {
distRun = distRunMiles;
return;
}
double RunnerInfo::GetSpeedMph() const {
return distRun / (timeRun / 3600.0);
}
int main() {
RunnerInfo runner1;
RunnerInfo runner2;
runner1.SetTime(360);
runner1.SetDist(1.2);
runner2.SetTime(200);
runner2.SetDist(0.5);
cout << "Runner1's speed in MPH: " << runner1.GetSpeedMph() << endl;
cout << "Runner2's speed in MPH: " << runner2.GetSpeedMph() << endl;
return 0;
}
class ClassName {
public:
private:
};