What does a trailing const on a member function mean?
-
A
It must be evaluated at compile time
-
B
It promises not to modify the object
Correct answer
-
C
It returns a constant value
-
D
It can be called only one time
Correct answer
B. It promises not to modify the object
14 views
Explanation
A const member function receives a const this pointer, so it cannot modify the object's data members.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ