Doubt about function overloading

sir i want to ask that :

int & ab(int & a);
int ab(int a);
int ab(int & a);
int & ab(int a);
const int ab(int a);

are all these functions also overloaded

Hi Bhavya, not all of these functions are overloaded. It is because overloaded methods must change the parameters list.

BUT in :
int & ab( int & a)
int ab( int & a)

is not overloaded as they have same parameter list and on compiling the compiler will raise an error.
Remeber:

  • Overloaded methods MUST change the argument list.
  • If it does then Overloaded methods CAN change the return type.

Hope this helps :slight_smile:

1 Like

okey thank you
it cleared my concepts.
thanks again

1 Like