1.

What is the output of this program?
#include <iostream>
#include <cmath>
using namespace std;
class ComplexNumber
{
private:
double RealNumber;
double ImagNumber;
public:
ComplexNumber(double r = 0.0, double i = 0.0) : RealNumber(r), ImagNumber(i)
{}
double mag()
{
return getMag();
}
operator double ()
{
return getMag();
}
private:
double getMag()
{
return sqrt(RealNumber * RealNumber + ImagNumber * ImagNumber);
}
};
int main()
{
ComplexNumber comp(2.0, 5.0);
cout << comp.mag()< cout << comp;
return 0;
}

A. 2.0
B. 5.0
C. 5.38516
D. 5.38516 5.38516
E. None of these
Answer» E. None of these


Discussion

No Comment Found

Related MCQs