adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include 
    #include 
    using namespace std;
    class Complex
    {
        private:
        float real;
        float imag;
        public:
        Complex():real(0), imag(0){}
        Complex operator ()(float re, float im)
        {
            real += re;
            imag += im;
            return *this;
        }
        Complex operator() (float re)
        {
            real += re;
            return *this;
        }
        void display()
        {
            cout << "(" << real << "," << imag << ")" << endl;
        }
    };
    int main()
    {
        Complex c1, c2;
        c2 = c1(3.2, 5.3);
        c1(6.5, 2.7);
        c2(1.9);
        cout << "c2=";c1.display();
        cout << "c2=";c2.display();
        return 0;
    }

a.

c2=(9.7,8) c2=(5.1,5.3)

b.

c2=(9,8) c2=(5,5)

c.

c2=(4.7,8) c2=(2.1,5.3)

d.

none of the mentioned

Answer: (a).c2=(9.7,8) c2=(5.1,5.3)

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?