Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Using template convert rectangular coordinate to polar using single argument constructor in polar

–1 vote
asked Sep 6, 2019 by The Biz Tv Productions (140 points)
//Help to debug the program it shows error with single arument constructor in class polar

template <class T>
class rectangular

{

public:

T xco,yco;

rectangular():xco(0),yco(0){}

rectangular(T x,T y):xco(x),yco(y){}

void display_rect()

{
cout<<"rectangular coordintaes:"<<xco<<","<<yco<<endl;

}

};

template <class S>

class polar

{

S radius,angle;

public:

polar();radius(0),angle(0){}

polar(rectangular r)

{

radius=sqrt(r.xco*r.xco+r.yco*r.yco);

angle=atan(r.yco/r.xco);

}

void display_polar()

{

cout<<"polar coordinates is"<<radius<<","<<angle<<endl;

}

};

void main()

{

polar<double> p;

rectangular <double> r(4.71,30.56);

p=r;

p.display_rect();

cout<<"After conversion"<<endl;

p.display_polar()

}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...