Question: write the int main for the below code in c++ and display it class complex { double real; double imaginary; public: complex() { real =
write the int main for the below code in c++ and display it
class complex
{
double real;
double imaginary;
public:
complex()
{
real = 0;
imaginary = 0;
}
void set_complex(double r,double i)
{
real =r;
imaginary =i;
}
double get_real()
{
return (real);
}
double
get_imaginary()
{
return
(imaginary);
}
char sign(double z)
{
return
((z< 0) ?'-':'+');
}
void display_complex()
{
if
(imaginary == 0)
cout < else if (real == 0 && imaginary != 0) cout << sign(imaginary) << "i"< else cout< } };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
