Explain function overloading in C++ with its return type and signature.

(Last Updated On: March 17, 2018)

Answer: Function overloading in C++ is the feature of having multiple functions in a class with same name with different return types and signatures. For example in below class we have three functions overloaded.



Function overloading is a compile time polymorphism and function calls are resolved at compile time itself.

It is important to focus that overloaded functions must have different signatures even though the return types are different. For example in below class compiler will throw an error i.e. “overloaded functions differ only by return type”




Compiler uses name mangling in C++ to understand different versions of overloaded functions.

Complete example of Function Overloading in C++

Subscribe class has two overloaded functions named “user”. One function will accept only user name and another one will accept user’s name and email address both to subscribe.


User name:Rakesh
User name:Rakesh       Email:r@r.com