InterviewSolution
Saved Bookmarks
| 1. |
Which among the following is recommended for const functions?(a) Const function use should be reduced in a program(b) Const function use should be more in a program(c) Const function use should not matter in a program(d) Const function use should be able to modify the valuesI have been asked this question during an online exam.Origin of the question is Constant Member Functions topic in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» RIGHT option is (B) Const function use should be more in a program For explanation: The const member FUNCTIONS should be used more in a program. The REASON behind is to ensure there is no accidental modification of data of object. Also to ensure any unintended modification which may result in unexpected termination of program. |
|