Program to Convert One Class To Another Class Type:
#include<iostream>
#include<math.h>
using namespace std;
class desti
{ public:
float x,y;
void display()
{
cout<<"\nValues Are\n"<<x<<"\n"<<y;
}
};
class p
{
float r;
float ang;
public:
p()
{
cout<<"Enter The Values Of Polar Form";
cin>>r>>ang;
ang=ang/57.2; }
operator desti()
{ cout<<sin(ang);
desti temp;
temp.x=ceil(r*cos(ang));
temp.y=ceil(r*sin(ang));
return temp;
}
};
main()
{
p a;
desti b;
b=a;
b.display();
}
#include<iostream>
#include<math.h>
using namespace std;
class desti
{ public:
float x,y;
void display()
{
cout<<"\nValues Are\n"<<x<<"\n"<<y;
}
};
class p
{
float r;
float ang;
public:
p()
{
cout<<"Enter The Values Of Polar Form";
cin>>r>>ang;
ang=ang/57.2; }
operator desti()
{ cout<<sin(ang);
desti temp;
temp.x=ceil(r*cos(ang));
temp.y=ceil(r*sin(ang));
return temp;
}
};
main()
{
p a;
desti b;
b=a;
b.display();
}