Default values for function are need to be specified from left to right only.
a. True
b. False
Submitted by: Administratorb. False
Explanation:
Default values need to be specified from Right to Left order.
Example:
void calculate(int amt, int years, float rate=7.8); //valid
void calculate(int amt, int years=5, float rate=7.8); //valid
void calculate(int amt=21000, int years, float rate=7.8); //Invalid
Third statement is invalid as we skipped second parameter of the function. Rule says that default values should be set from Right to Left order only. We cannot provide a default value to specific parameter in the middle of an parameter list.
Submitted by:
Explanation:
Default values need to be specified from Right to Left order.
Example:
void calculate(int amt, int years, float rate=7.8); //valid
void calculate(int amt, int years=5, float rate=7.8); //valid
void calculate(int amt=21000, int years, float rate=7.8); //Invalid
Third statement is invalid as we skipped second parameter of the function. Rule says that default values should be set from Right to Left order only. We cannot provide a default value to specific parameter in the middle of an parameter list.
Submitted by:
Read Online C++ Inline Function Job Interview Questions And Answers
Top C++ Inline Function Questions
☺ | Define Inline Function? |
☺ | Explain what are static member functions? |
☺ | Tell me what happens when recursion functions are declared inline? |
☺ | Please explain, do inline functions improve performance? |
☺ | Explain advantages and disadvantages of using macro and inline functions? |
Top C Plus Plus Language Categories
☺ | C++ Pointers & Functions Interview Questions. |
☺ | C++ Operator Overloading Interview Questions. |
☺ | C++ Exception Handling Interview Questions. |
☺ | C++ Virtual Functions Interview Questions. |
☺ | C++ Template Interview Questions. |