convert coordinateclass


Convert coordinate:

class rect{

                private :

                float  x,y;

 

                public :

                void  input()

                {

                cout <<"enter rect coords\n";

                cin >> x>> y>>"\n";

                }

                void output()

                {

                                cout << x<<"\n" << y;

                }

                rect ()//dummy consructor

                {

                }

                rect (float a,float b)//constructor

                {

                x=a;

                y=b;

                }

                }; //end of class

 

                class polar {

                private :

                float r,q;

 

                public :

                void input()

                {

                cout <<"enter polar coords\n";

                cin>>r>>q;

 

                }

                void output()

                {

                cout << r<

                }

                operator rect();

                };//end of class

 

       polar :: operator rect()

                                {

                                float a=r*cos(22*q/(7*180));

                                float b=r*sin(22*q/(7*180));

                                return rect(a,b);//calling constructor inbuild that it will

                                                                 //return rect type

                                }

    void main()

    {

 

    rect a;

    polar p;

    clrscr();

    p.input();

    a=p;

    a.output();

    getch();

    }

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: convert coordinateclass
Reference No:- TGS0174770

Expected delivery within 24 Hours