Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"stdafx.h"
- #include "string"
- #include <iostream>
- /*
- write a cpp class to claculate distnace as the following
- -create object to distnace between kirkuk and baghdad
- -create object to distnace between baghdad and basra
- -calculate distance between kirkuk and basra
- */
- using namespace std;
- class distnace {
- private:
- int dis;
- public:
- distnace(int d) {
- dis = d;
- }
- distnace() {
- }
- void print_dis() {
- cout << dis << endl;
- }
- int get_dis() {
- return dis;
- }
- };
- int main()
- {
- distnace kb(100), bb(70), kba;
- cout << "distnace : ";
- kb.print_dis();
- cout << "distnace 2 : ";
- bb.print_dis();
- kba = kb.get_dis() + bb.get_dis();
- cout << "dis : ";
- kba.print_dis();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement