Home » C++ Programming » Functions » Question
  1. 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;
    }
    1. First Distance : 15
      Second Distance :150
    2. First Distance : 150
      Second Distance :15
    3. First Distance : 25160
      Second Distance :1215
    4. First Distance : 1215
      Second Distance :25160
    5. None of these
Correct Option: D

We are calculating the foot and inches by using the function call operator.



Your comments will be displayed only after manual approval.