In C++, following function declarations cannot be overloaded.
1) Function declarations that differ only in the return type. For example, the following program fails in compilation.
2) Member function declarations with the same name and the name parameter-type-list cannot be overloaded if any of them is a static member function declaration. For example, following program fails in compilation.
3) Parameter declarations that differ only in a pointer * versus an array  are equivalent. That is, the array declaration is adjusted to become a pointer declaration. Only the second and subsequent array dimensions are significant in parameter types. For example, following two function declarations are equivalent.
4) Parameter declarations that differ only in that one is a function type and the other is a pointer to the same function type are equivalent.
5) Parameter declarations that differ only in the presence or absence of const and/or volatile are equivalent. That is, the const and volatile type-specifiers for each parameter type are ignored when determining which function is being declared, defined, or called. For example, following program fails in compilation with error “redefinition of `int f(int)’ “
Only the const and volatile type-specifiers at the outermost level of the parameter type specification are ignored in this fashion; const and volatile type-specifiers buried within a parameter type specification are significant and can be used to distinguish overloaded function declarations. In particular, for any type T,
“pointer to T,” “pointer to const T,” and “pointer to volatile T” are considered distinct parameter types, as are “reference to T,” “reference to const T,” and “reference to volatile T.” For example, see the example in this comment posted by Venki.
6) Two parameter declarations that differ only in their default arguments are equivalent. For example, following program fails in compilation with error “redefinition of `int f(int, int)’ “
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- What are the operators that can be and cannot be overloaded in C++?
- Hiding of all overloaded methods with same name in base class
- Can main() be overloaded in C++?
- Static functions in C
- Write one line functions for strcat() and strcmp()
- Can static functions be virtual in C++?
- Virtual functions in derived classes
- Some interesting facts about static member functions in C++
- Functions that are executed before and after main() in C
- Pure Functions
- Can virtual functions be private in C++?
- Virtual Functions and Runtime Polymorphism in C++ | Set 1 (Introduction)
- Can virtual functions be inlined?
- Macros vs Functions
- fill() and fill_n() functions in C++ STL
- Return from void functions in C++
- Forward List in C++ | Set 1 (Introduction and Important Functions)
- Forward List in C++ | Set 2 (Manipulating Functions)
- List in C++ | Set 2 (Some Useful Functions)
- isalpha() and isdigit() functions in C with cstring examples.