C++ Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 3)
3.
Which of the following statement is correct?
Overloaded functions can have at most one default argument.
An overloaded function cannot have default argument.
All arguments of an overloaded function can be default.
A function if overloaded more than once cannot have default argument.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
15 comments Page 1 of 2.

Sasi said:   1 decade ago
the parameters will be changed but not the functionality and the arguments in the function .

Abin said:   1 decade ago
Option c is correct. It is not a matter weather the parameter is default or not!

Aditi said:   1 decade ago
The trailing arguments of the function can have default arguments.

Shalin said:   1 decade ago
But say there are 2 functions one has one argument and other has 2 arguments and if I keep parameters blank while calling this function which one should be called as default arguments are defined in both of them?

Joel said:   1 decade ago
include<stdio.h>
int main ()
{
int a;
int b;
printf("please enter the number a&b");
scanf(%d,%d:&a and &b);

return0;

}

Seema said:   1 decade ago
void fun(int a=10,int b=20);

void fun();

main()
{
fun();
}

Which function will be called in main() first or second?
(1)

Pankaj sharma said:   1 decade ago
void fun(int a=10,int b=20);
void fun();
main()
{
fun();
}

Ambiguous situation so error.

Kapil makwana said:   1 decade ago
void fun(int a=10,int b=20);

void fun();

main()
{
fun();
}

Which function will be called in main() first or second?

Sonu Rajpoot said:   1 decade ago
void fun(int a=10,int b=20);

void fun();

main()
{
fun();
}

Error would occur.
(1)

Smruti mishra said:   1 decade ago
void fun(int a=10,int b=20);
void fun();
main()
{
fun();
}

Error will occur because redeclaration of function is type mismatch.
(2)


Post your comments here:

Your comments will be displayed after verification.