C++ Programming - OOPS Concepts - Discussion
Discussion Forum : OOPS Concepts - General Questions (Q.No. 20)
20.
Which of the following is correct about function overloading?
Discussion:
14 comments Page 1 of 2.
Ahmed Redha said:
6 years ago
Two functions are overloaded if they have the same name but different arguments (parameter list).
Two parameter lists are different if :
1) They have a different number of arguments.
2) They have the same number of arguments but differ in the type of one argument at least.
3) They have the same number of arguments and data types but with a different order.
@Viranshukumar.
The example which you given is not correct since all arguments have the same type so the order is meaningless.
Two parameter lists are different if :
1) They have a different number of arguments.
2) They have the same number of arguments but differ in the type of one argument at least.
3) They have the same number of arguments and data types but with a different order.
@Viranshukumar.
The example which you given is not correct since all arguments have the same type so the order is meaningless.
(2)
Gelu Menumorut said:
9 years ago
First, the arguments don't count here, only the parameters count.
Then, the order of the parameters doesn't count if their type is the same, so 'B' doesn't apply.
In case the types are different and their order is different, that means different parameters' types so this case is covered by 'A'.
Then, the order of the parameters doesn't count if their type is the same, so 'B' doesn't apply.
In case the types are different and their order is different, that means different parameters' types so this case is covered by 'A'.
Gunvant said:
1 decade ago
C++ allows you to specify more than one definition for a function name or an operator in the same scope, which is called function overloading and operator overloading respectively.
Roopesh said:
1 decade ago
Function overloading means using the same function to perform different tasks.
So the name will be same. But the data types and number of arguments may vary.
So the name will be same. But the data types and number of arguments may vary.
Mphatso said:
1 decade ago
Function overload can have the same number of argument but different of different types. So I think the correct answer should be A, B, C.
Viranshukumar said:
1 decade ago
Option B is not correct because :
int fun (int a, int b, int c)
Here I change the order or arguments.
int fun (int b, int c, int a)
int fun (int a, int b, int c)
Here I change the order or arguments.
int fun (int b, int c, int a)
SALEHA said:
1 decade ago
In function overloading function has same name but accessing depends on the no. And type of arguments so, answer is option A & B.
VRushabh said:
8 years ago
int foo(int a,float b){ } and int foo(float a,int b){} are different.
This shows function arguments order difference.
This shows function arguments order difference.
Baru said:
1 decade ago
Function overloading definition it contain same name but different datatype n return type n arguments list.
Sangee said:
1 decade ago
Overloading is nothing but same function with different arguments.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers