Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
#include
3.
using namespace std;
4.
class Complex
5.
{
6.
private:
7.
float real;
8.
float imag;
9.
public:
10.
Complex():real(0), imag(0){}
11.
Complex operator ()(float re, float im)
12.
{
13.
real += re;
14.
imag += im;
15.
return *this;
16.
}
17.
Complex operator() (float re)
18.
{
19.
real += re;
20.
return *this;
21.
}
22.
void display()
23.
{
24.
cout
Options:
A .  static member function
B .  non-static member function
C .  dynamis_cast
D .  static_cast
Answer: Option B

Answer: (a)
Explanation: 
In this program, We are returning the real and imaginary part of the complex number by using function call operator.
Output:
$ g++ call3.cpp
$ a.out
c2=(9.7,8)
c2=(5.1,5.3)



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers