Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class shaid{
- public:
- virtual void print()=0;
- };
- class trriangle : public shaid{
- public:
- int a;
- int h;
- void print(){
- int S= (a*h)*0.5;
- cout << S << endl;
- }
- };
- class rectangl : public shaid{
- public:
- int a;
- int b;
- void print(){
- int S= a*b;
- cout << S << endl;
- }
- };
- class circle : public shaid{
- public:
- int r;
- int pi;
- void print(){
- int S= pi*(r*r*r);
- cout << S << endl;
- }
- };
- int main()
- {
- /*
- triangl d = dog();
- restangle c = cat();
- d.print();
- c.print();
- dog*a = new dog();
- cat*b = new cat();
- a->print();
- (*b).print();
- animal*df = new animal();
- df->print();
- animal*cl = new cat();
- cl->print();
- */
- shaid*hg =new trriangle();
- hg->print();
- shaid*ab = new rectangl();
- ab->print();
- shaid*uf = new circle();
- uf->print();
- }
Advertisement
Add Comment
Please, Sign In to add comment