Answer to Question #192883 in C++ for Sankalp

Question #192883

Write a class and member functions for a class complex as followsClass complex{int re, img;public :complex(int =0, int=0);complex(complex &);void accept();void display();complex add(const complex &);

1
Expert's answer
2021-05-16T13:19:45-0400
#include <iostream>

using namespace std;
class Complex
{
    int re,img;
    public:
           Complex();
           Complex(int, int);
           void accept();
           void Display();
};
Complex:: Complex()
{
 re = 0;
 img = 0;
}

Complex::Complex(int r, int i)
{
int re = r;
int img = i;
}

void Complex::Display()
{
cout<<re<<"+"<<img<<" i"<<endl;
}
int main()
{
     Complex c1 (0,0);
     c1.Display();
        return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment