1.

How does the compiler interpret more than one definitions having same name? What steps does it follow to distinguish these?

Answer»

The compiler will follow the following steps to interpret more than one definitions having same name:

(i) if the signatures of subsequent functions match the previous function’s, then the second is treated as a redeclaration of the first.

(ii) if the signature of the two functions match exactly but the return type differ, the second declaration is treated as an erroneous re-declaration of the first and is flagged at compile time as an error.

(iii) if the signature of the two functions differ in either the number or type of their arguments, the two functions are considered to be overloaded.



Discussion

No Comment Found

Related InterviewSolutions