Function Overloading
Yogendra Pal
At the end of this tutorial you will be able to
• Explain function signature.
• Differentiate functions on the basis of th...
Function Overloading / Function Polymorphism
• Polymorphism (बहुरूपता) means having many forms.
• Function polymorphism: A...
Function Signature / Argument List
• Argument list of a function defines it’s signature.
• Signature of a function is diff...
Call an overloaded function
• void setTime( );
• void setTime(int hh);
• void setTime(int hh, double mm);
• void setTime(d...
Ambiguous Call
• void setTime(int hh, double mm);
• void setTime(double mm, int hh);
• setTime(5, 1.2)
• setTime(4.2, 5)
•...
Ask your questions
to learn better
Yogendra Pal
www.learnbywatch.com | yogendra@learnbywatch.com
Próxima SlideShare
Cargando en…5
×

Function overloading in c++

747 visualizaciones

Publicado el

How to overload functions in C++ programming language.

Publicado en: Educación
  • Sé el primero en comentar

  • Sé el primero en recomendar esto

Function overloading in c++

  1. 1. Function Overloading Yogendra Pal
  2. 2. At the end of this tutorial you will be able to • Explain function signature. • Differentiate functions on the basis of their signature. • Explain function overloading. • Identify overloaded functions from a given c++ program. • Identify which function will execute on a call to overloaded function. • Identify an ambiguous function call. • Write overloaded functions in a c++ program. www.learnbywatch.com | yogendra@learnbywatch.com
  3. 3. Function Overloading / Function Polymorphism • Polymorphism (बहुरूपता) means having many forms. • Function polymorphism: A function in many forms. • The process of creating same named functions is called function overloading. • Such functions are called overloaded functions. • In C++ two functions can have same name as long as their signatures are different. www.learnbywatch.com | yogendra@learnbywatch.com
  4. 4. Function Signature / Argument List • Argument list of a function defines it’s signature. • Signature of a function is different if any one of the following is different. • Number of arguments, • Data Type of arguments and • Order of arguments. www.learnbywatch.com | yogendra@learnbywatch.com void setTime( ); void setTime(int hh); void setTime(int hh, double mm); void setTime(double hh); void setTime(double mm, int hh);
  5. 5. Call an overloaded function • void setTime( ); • void setTime(int hh); • void setTime(int hh, double mm); • void setTime(double hh); • void setTime(double mm, int hh); • setTime(12.5) • setTime(12.5 , 7) • setTime() • setTime(7, 12.5) • setTime(7) www.learnbywatch.com | yogendra@learnbywatch.com
  6. 6. Ambiguous Call • void setTime(int hh, double mm); • void setTime(double mm, int hh); • setTime(5, 1.2) • setTime(4.2, 5) • setTime(2, 3) • setTime(2.1, 4.5) www.learnbywatch.com | yogendra@learnbywatch.com
  7. 7. Ask your questions to learn better Yogendra Pal www.learnbywatch.com | yogendra@learnbywatch.com

×