1.

If a function is to be made const, which is the correct syntax?(a) const functionName(parameters);(b) const returnType functionName(parameters);(c) const functionName(returnType)(Parameters);(d) const (functionName(parameters));This question was addressed to me in an interview.This question is from Constant Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (b) const RETURNTYPE FUNCTIONNAME(parameters);

To explain I would say: The function declaration must contain the keyword const. The const keyword makes the function const type. The usual function declaration can be GIVEN followed by the keyword. The keyword const can be given after the declaration of function and before DEFINITION.



Discussion

No Comment Found

Related InterviewSolutions