Skip to content

Instantly share code, notes, and snippets.

@sprintr
Created May 22, 2013 15:21
Show Gist options
  • Select an option

  • Save sprintr/5628440 to your computer and use it in GitHub Desktop.

Select an option

Save sprintr/5628440 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
class Distance {
private:
int feet;
double inches;
public:
void getdistance() {
cout << "Enter feet: " << endl;
cin >> feet;
cout << "Enter inches: " << endl;
cin >> inches;
}
void setdistance(int ft, double in) {
feet = ft;
inches = in;
}
void showdistance() {
cout << feet << "\'-" << inches << "\"" << endl;
}
};
int main() {
Distance dist1, dist2;
dist1.setdistance(11, 6.25);
dist1.showdistance();
dist2.getdistance();
dist2.showdistance();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment