C++ Access Control Question:
Download Questions PDF

Default values for a function are need to be specified from left to right only.

a. True
b. False

Answer:

b. False
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.

Download C++ Access Control Interview Questions And Answers PDF

Previous QuestionNext Question
If a program uses Inline Function, then the function is expanded inline at ___________.

a. Compile time
b. Run time
c. Both a and b
d. None of these
Which of the followings is/are not false about friend function ?

1. It can be called / invoked with class object
2. It has objects as arguments
3. It can have built-in types as arguments
4. It must declared only in public part of a class
5. It does not have this pointer as an argument

a. Only 2,4
b. Only 1,2,5
c. Only 2,3,5
d. All of these