C++ Programming - Functions - Discussion
Discussion Forum : Functions - General Questions (Q.No. 6)
6.
Which of the following statement is incorrect?
Discussion:
8 comments Page 1 of 1.
Satya said:
1 decade ago
The question says "default argument cannot be provided for pointers to functions. " is incorrect.
(1)
Ash said:
1 decade ago
Why Default argument cannot be provided for pointers to functions?
KernelRoot said:
1 decade ago
@Ash.
Read the question correctly, Default arguments can be provided for pointers and functions.
Read the question correctly, Default arguments can be provided for pointers and functions.
Archana said:
1 decade ago
Can anyone give the right explanation for this question with example?
Kahramon said:
1 decade ago
The answer is already obsolete!
The C++ compiler does not allow default arguments on pointers to functions.
This code was accepted by the previous version's compiler but now gives an error. For code that works in all versions of Visual C++, do not assign a default value to a pointer-to-function argument.
The C++ compiler does not allow default arguments on pointers to functions.
This code was accepted by the previous version's compiler but now gives an error. For code that works in all versions of Visual C++, do not assign a default value to a pointer-to-function argument.
Harshil said:
10 years ago
The default argument is part of a function declaration but it is not part of its type. So you can write:
void f(int x = 0);
But the type of f is still.
void(int x)
And consequently, a pointer to function type cannot include default arguments.
void f(int x = 0);
But the type of f is still.
void(int x)
And consequently, a pointer to function type cannot include default arguments.
Navya said:
10 years ago
In a function, all the arguments can be default. Then why did you declare C as the only correct option?
Pratik Tembhare said:
3 years ago
Thanks for explaining.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers