If all required header files are already included, identify the output of the…
2022
If all required header files are already included, identify the output of the following C++ code from the given options:
- A.
1001 : 1
- B.
1001 : 4
- C.
1001 : 3
- D.
1001 : 2
Attempted by 160 students.
Show answer & explanation
Correct answer: B
Student S(1001); → Constructor is called with AN = 1001 and default C = 1 → AdmNo = 1001, Class = 1 S.Promoted(3); → Class += 3 → Class = 1 + 3 = 4 S.Display(); prints → 1001 : 4