Samsung Interview Question
Software Engineer / DevelopersCountry: -
Interview Type: In-Person
C++ does not support overloading by return type. Other languages might, if they can infer from context which type is needed in a particular expression.
I don't think any language can support overloading by return type. Ex: int ans=f(x,y) double ans=f(x,y)how can I know which function to call ? based on the type of answer it assign to?
not sure but chk this.
generallly associativity of assignment operator is Right To Left. so in an assignment operator function is first called, and that point f time it does not know about the right hand side variable's data type and i think this is the reason for compiler not supporting overload of function having same signature but diff return type.
please correct me if i m wrong
Well Good but Known Question.
- Prem October 11, 20111> Primarily the answer is Return type plays no Role in this mechanism and if someOne mistakenly did than in C++ compiler shouts...
2> However in different argument variable types. Actually C++ Compiler optimizes the function Name in Symbol Table by appending internal reference mechanism which can be deference internally. This is clearly visible if some one check the polymorphism using virtual pointer and virtual table.