Which of the following overloaded functions are NOT allowed in C++?
1) Function declarations that differ only in the return type
int fun(int x, int y);
void fun(int x, int y);
2) Functions that differ only by static keyword in return type
int fun(int x, int y);
static int fun(int x, int y);
3)Parameter declarations that differ only in a pointer * versus an array []
int fun(int *ptr, int n); int fun(int ptr[], int n);
4) Two parameter declarations that differ only in their default arguments
int fun( int x, int y); int fun( int x, int y = 10);
(A) All of the above
(B) All except 2)
(C) All except 1)
(D) All except 2 and 4
Answer: (A)
Explanation: See Function overloading in C++
Quiz of this Question
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.
Recommended Posts:
- C++ | Function Overloading and Default Arguments | Question 5
- C++ | Function Overloading and Default Arguments | Question 2
- C++ | Function Overloading and Default Arguments | Question 4
- C++ | Function Overloading and Default Arguments | Question 5
- Default arguments and virtual function
- Templates and Default Arguments
- Some Interesting facts about default arguments in C++
- getopt() function in C to parse command line arguments
- Function overloading and const keyword
- Function Overloading and float in C++
- Default Assignment Operator and References
- When does compiler create default and copy constructors in C++?
- Does C support function overloading?
- How to Count Variable Numbers of Arguments in C?
- When do we pass arguments by reference or pointer?
- Variable length arguments for Macros
- Command line arguments in C/C++
- Command line arguments example in C
- C++ | Operator Overloading | Question 10
- C++ | Operator Overloading | Question 2

