SHARE
TWEET

cplus

Dprogrammed1 Apr 1st, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.     using namespace std;
  3.     class Distance
  4.     {
  5.         private:
  6.         int feet;
  7.         int inches;
  8.         public:
  9.         Distance()
  10.         {
  11.             feet = 0;
  12.             inches = 0;
  13.         }
  14.         Distance(int f, int i)
  15.         {
  16.             feet = f;
  17.             inches = i;
  18.         }
  19.         Distance operator()(int a, int b, int c)
  20.         {
  21.             Distance D;
  22.             D.feet = a + c + 10;
  23.             D.inches = b + c + 100 ;
  24.             return D;
  25.         }
  26.         void displayDistance()
  27.         {
  28.             cout  << feet <<  inches << endl;
  29.         }
  30.     };
  31.     int main()
  32.     {
  33.         Distance D1(11, 10), D2;
  34.         cout << "First Distance : ";
  35.         D1.displayDistance();
  36.         D2 = D1(10, 10, 10);
  37.         cout << "Second Distance :";
  38.         D2.displayDistance();
  39.         return 0;
  40.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top