Functions declarations which cannot be overloaded

Generally there is a confusion among students regarding the function overloading.So it is an important part to be covered for interviews.Companies often asked function overloading questions which are generally tricky and confuse students.So here are some functions which cannot be overloaded in C++.

1) Function declaration that differ only in return type cannot be overloaded.

2) Member function with the same name and the parameter list cannot be overloaded if any of them is static member function declaration.

ex : static void func(int i)
               void func(int i)

3) Parameter declaration that differ only in a pointer (*) versus an array [] are equivalent and hence cannot be overloaded.

ex : int func(int *p)
      int func(int p[])

4) The function declaration with parameter having const keyword is equivalent to normal parameter declaration hence cannot be overloaded.

ex : int func(int x)
      int func(const int x)

5) The function declaration in which one parameter variable is defined then it is also equivalent to function in which no parameter variable is defined.So it cannot be overloaded.

ex : int func(int x,int y)
      int func(int x=9,int y=5)

Comments

Popular posts from this blog

Tricky Questions or Puzzles in C

Program to uncompress a string ie a2b3c4 to aabbbcccc

Number series arrangement puzzles