//Ex6_21.cpp
#include "iostream"
#include <cmath> 
using namespace std;
class base
{protected: 
      int x,y;
public:
   virtual void setx(int i,int j=0)
     {x=i; y=j;}
    virtual void disp()=0; 
};

class square:public base
{public:
   void disp()
        {cout<<x*x<<endl;}
};
class cube:public base
{public:
   void disp()
     {cout<<x*x*x<<endl;}
};
class chpow:public base
{public:
   void disp()
      {cout<<pow(x,y)<<endl;}
};
void main()
{base *ptr;                 
 square B; 
 cube C;
 chpow D;
 ptr=&B;
 ptr->setx(5);
 ptr->disp();
 ptr=&C;
 ptr->setx(6);
 ptr->disp();
 ptr=&D;
 ptr->setx(3,4);
 ptr->disp();
 }  
