Computer Science - Object Oriented Programming Using C++ - Discussion
Discussion Forum : Object Oriented Programming Using C++ - Section 2 (Q.No. 1)
1.
When you omit parameters from a function call, values can be provided by
Discussion:
2 comments Page 1 of 1.
Ayesha... said:
4 years ago
Once we provide a default value for a parameter, all subsequent parameters must also have default values.
For example:
// Invalid
void add(int a, int b = 3, int c, int d);
// Invalid
void add(int a, int b = 3, int c, int d = 4);
// Valid
void add(int a, int c, int b = 3, int d = 4);
For example:
// Invalid
void add(int a, int b = 3, int c, int d);
// Invalid
void add(int a, int b = 3, int c, int d = 4);
// Valid
void add(int a, int c, int b = 3, int d = 4);
Jjj said:
1 decade ago
Default Function Arguments
A function can be called without specifying all its arguments. The function declaration must provide default values for those arguments that are not specified.
A function can be called without specifying all its arguments. The function declaration must provide default values for those arguments that are not specified.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers