SHARE
TWEET

cplus

Dprogrammed1 Apr 1st, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.     using namespace std;
  3.     class poly
  4.     {
  5.         protected:
  6.         int width, height;
  7.         public:
  8.         void set_values(int a, int b)
  9.         {
  10.             width = a; height = b;
  11.         }
  12.     };
  13.     class Coutput
  14.     {
  15.         public:
  16.         void output(int i);
  17.     };
  18.     void Coutput::output(int i)
  19.     {
  20.         cout << i;
  21.     }
  22.     class rect:public poly, public Coutput
  23.     {
  24.         public:
  25.         int area()
  26.         {
  27.             return(width * height);
  28.         }
  29.     };
  30.     class tri:public poly, public Coutput
  31.     {
  32.         public:
  33.         int area()
  34.         {
  35.             return(width * height / 2);
  36.         }
  37.     };
  38.     int main()
  39.     {
  40.         rect rect;
  41.         tri trgl;
  42.         rect.set_values(3, 4);
  43.         trgl.set_values(4, 5);
  44.         rect.output(rect.area());
  45.         trgl.output(trgl.area());
  46.         return 0;
  47.     }
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