1.

Which public function call among the following is correct outside the class, if return type is void (C++)?(a) object.void functionName(parameters);(b) object.functionName(parameters);(c) object.functionName void (parameters)(d) object.void functionName();This question was posed to me in an interview for internship.Question is from Public Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

The correct OPTION is (b) object.functionName(parameters);

Easiest explanation - The condition given says that there is no return TYPE HENCE we can call the FUNCTION DIRECTLY. The object name should be mentioned with a dot operator to access its class members. Then the function name with parameters, if required, can be given.



Discussion

No Comment Found

Related InterviewSolutions