-
What is the output of this program?
#include <iostream>
using namespace std;
class DistanceExample
{
private:
int F;
int I;
public:
DistanceExample()
{
F = 0;
I = 0;
}
DistanceExample(int feet, int inche)
{
F = feet;
I = inche;
}
DistanceExample operator()(int P, int Q, int R)
{
DistanceExample Dist;
Dist.F = P + R + 15;
Dist.I = P + R + 150 ;
return Dist;
}
void displayDistance()
{
cout << F << I << endl;
}
};
int main()
{
DistanceExample Dist1(12, 15), Dist2;
cout << "First Distance : ";
Dist1.displayDistance();
Dist2 = Dist1(5, 5, 5);
cout << "Second Distance :";
Dist2.displayDistance();
return 0;
}
-
- First Distance : 15
Second Distance :150 - First Distance : 150
Second Distance :15 - First Distance : 25160
Second Distance :1215 - First Distance : 1215
Second Distance :25160 - None of these
- First Distance : 15
Correct Option: D
We are calculating the foot and inches by using the function call operator.