Vidyalelo
C++ Programming · Q188

Classes and Objects in C++

Programming · C++ Programming · question 188

Q188

What will be the output of the following C++ code? #include using namespace std; class Distance private: int feet; int inches; public: Distance() feet = 0; inches = 0; Distance(int f, int i) feet = f; inches = i; Distance operator()(int a, int b, int c) Distance D; D.feet = a + c + 10; D.inches = b + c + 100 ; return D; void displayDistance() cout << feet << inches << endl; ; int main() Distance D1(11, 10), D2; cout << "First Distance : "; D1.displayDistance(); D2 = D1(10, 10, 10); cout << "Second Distance :"; D2.displayDistance(); return 0;

A.
First Distance : 1110
Second Distance :30120
Answer
B.
First Distance : 110
Second Distance :3020
C.
First Distance : 1115
Second Distance :30125
D.
First Distance : 100
Second Distance :30120

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board