
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
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 }
- Related Articles
- Functions that cannot be overloaded in C++
- Can main() be overloaded in C++?
- Operators that cannot be overloaded in C++
- Why can't static method be abstract in Java?
- How can group functions be used in ORDER BY clause?
- Prove that the $n^{th}$ term of an A.P. can't be $n^2+1$.
- How to create a variable that can be set only once but isn't final in Java?
- Program to find length of subsequence that can be removed still t is subsequence of s in Python
- Why a virus can't be killed using antibiotics?
- What are the different ways for a method to be overloaded in C#?
- Why can't Java generics be used for static methods?
- How MySQL aggregate functions can be combined with MySQL IF() function?
- Why can't variables be declared in a switch statement in C/C++?
- Overloaded method and ambiguity in C#
- What are overloaded indexers in C#?

Advertisements