C++ Programming - Functions - Discussion
Discussion Forum : Functions - General Questions (Q.No. 3)
3.
Which of the following statement is correct?
Discussion:
16 comments Page 1 of 2.
Priya said:
7 years ago
I think that option B is correct because the overloaded function should be varied in type and number of argument, in that case, if we declare a function with default argument, the compiler gets confused to execute the correct function.
(1)
Pavi said:
2 months ago
I think option B is correct because the overloaded function is executed based on the parameters given in the function call.
If we give default arguments means the compiler must be confused about executing the function.
If we give default arguments means the compiler must be confused about executing the function.
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?
Pradnya said:
9 years ago
@Pradhnya.
Only option c is correct answer because it says//*All arguments of an overloaded function "CAN BE " default*// means that It does not matter weather the parameter is default or not.
Only option c is correct answer because it says//*All arguments of an overloaded function "CAN BE " default*// means that It does not matter weather the parameter is default or not.
Purvi said:
9 years ago
That means the answer is incorrect, because when we call the function, it is differentiated by the different argument type, that is only overloading.
Can someone give a reason?
Can someone give a reason?
(1)
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;
}
int main ()
{
int a;
int b;
printf("please enter the number a&b");
scanf(%d,%d:&a and &b);
return0;
}
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.
void fun();
main()
{
fun();
}
Error will occur because redeclaration of function is type mismatch.
(2)
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?
void fun();
main()
{
fun();
}
Which function will be called in main() first or second?
(1)
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?
void fun();
main()
{
fun();
}
Which function will be called in main() first or second?
Sasi said:
1 decade ago
the parameters will be changed but not the functionality and the arguments in the function .
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers