C++ Programming - OOPS Concepts - Discussion

Discussion Forum : OOPS Concepts - General Questions (Q.No. 20)
20.
Which of the following is correct about function overloading?
The types of arguments are different.
The order of argument is different.
The number of argument is same.
Both A and B.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
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.
(2)

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.

Balaji said:   8 years ago
What is meant by order of arguments?

Smarty said:   9 years ago
Please explain it with an example.

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'.

Varun Aggarwal said:   10 years ago
How is argument different?

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)

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.

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.


Post your comments here:

Your comments will be displayed after verification.