
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Functions That Can't Be Overloaded in C++
In C++, we can overload the functions. But sometimes the overloading is not done. In this section, we will see what are the different cases, in which we cannot overload the functions.
When function signatures are same, only the return type is different, then we cannot overload the function.
int my_func() { return 5; } char my_func() { return 'd'; }
When the member functions have the same name and same parameter list in a class, then they cannot be overloaded.
class My_Class{ static void func(int x) { //Something } void func(int x) { //something } };
When the parameter declaration, that differs only in a pointer * and an array [] are same.
int my_func(int *arr) { //Do something } int my_func(int arr[]) { //do something }
When the parameter declaration, that differs only in a presence of constant or volatile qualifier are same.
int my_func(int x) { //Do something } int my_func(const int x) { //do something }
When the parameter declaration, that differs only in their default arguments are equivalent.
int my_func(int a, int b) { //Do something } int my_func(int a, int b = 50) { //do something }
Advertisements