FUNCTION OVERLOADING IN C++

Maha

 

Function Overloading   

  • It is an oops concept, where one function name takes different arguments.
  • Simply, Same function name different argument.
  • C++ also permits overloading of functions. 
  • We overload the single function again and again, with different arguments.
  • The argument count may change.
  • The argument type may change.

Program:

#include<iostream.h>
class funover
{
public:
void sum(int x, int y)
{
cout<<x+y;
}
void sum(int x, int y, int z)
{
cout<< x+y+z;
}
};
void main()
{
funover obj;
obj.sum(10,20);
obj.sum(10,20,30);
}

Output:


Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send