Overloading
- What is the output of this program?
#include
using namespace std;
int function(int N, int M, int O)
{
return N + M;
}
double function(double N, double M, double O)
{
return N + M;
}
int main()
{
cout << function(7, 16);
cout << function(15.05, 61.16);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
Compilation Error
In function 'int main()':
13:31: error: no matching function for call to 'function(int, int)'
13:31: note: candidates are:
3:9: note: int function(int, int, int)
3:9: note: candidate expects 3 arguments, 2 provided
7:12: note: double function(double, double, double)
7:12: note: candidate expects 3 arguments, 2 provided
14:38: error: no matching function for call to 'function(double, double)'
14:38: note: candidates are:
3:9: note: int function(int, int, int)
3:9: note: candidate expects 3 arguments, 2 provided
7:12: note: double function(double, double, double)
7:12: note: candidate expects 3 arguments, 2 provided
- What is the output of this program?
#include
using namespace std;
void function(int n)
{
cout << n<<" ";
}
void function(double m)
{
cout << m;
}
int main(void)
{
function(10);
function(50.36);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In this program, we are printing the values and the values will be print(10) will be printed first because of the order of the execution.
- Function overloading is also similar to which of the following?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In constructor overloading, we will be using the same options availed in function overloading.
- In which of the following we cannot overload the function?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
While overloading the return function, it will rise a error, So we can’t overload the return function.
- Which of the following permits function overloading on c++?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
type & number of arguments