Make Your Search Easy ! :) Use me

Friday, February 17, 2017

Static Stack


Program to implement Static Stack :-

#include<iostream>
#include<conio.h>


class base1
{
   int p,q;
     public:
     void base1_get()
      {
         cout<<"Enter Value of P :";
           cin>>p;
           cout<<"Enter Value of Q :";
           cin>>q;
        }
     void base1_show()
      {
          cout<<"\nData of Base 1";
         cout<<"\nP = "<<p;
           cout<<"\nQ = "<<q;
        }

  };
class base2
{
   int r,s;
     public:
     void base2_get()
      {
         cout<<"Enter Value of R :";
           cin>>r;
           cout<<"Enter Value of S :";
           cin>>s;
        }
     void base2_show()
      {
         cout<<"\nData of Base 2";
           cout<<"\nR = "<<r;
           cout<<"\nS = "<<s;
        }
  };

class derived:public base1,public base2
{
   int a,b;
     public:
     void derived_get()
      {
         cout<<"Enter Value of A :";
           cin>>a;
           cout<<"Enter Value of B :";
           cin>>b;
        }
     void derived_show()
      {
         cout<<"\nData of Derived";
           cout<<"\nA = "<<a;
           cout<<"\nB = "<<b;
        }
  };

void main()
{
   derived d;
     d.base1_get();
     d.base2_get();
     d.derived_get();
     clrscr();
     d.base1_show();
     d.base2_show();
     d.derived_show();
     getch();
  }

No comments:

Post a Comment