Home / C++ Programming / Functions - C++ :: General Questions

C++ Programming :: Functions - C++

  1. Which of the following function prototype is perfectly acceptable?

  2. A.
    int Function(int Tmp = Show());
    B.
    float Function(int Tmp = Show(int, float));
    C.
    Both A and B.
    D.
    float = Show(int, float) Function(Tmp);

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which of the following statement is correct?

  4. A.
    C++ enables to define functions that take constants as an argument.
    B.
    We cannot change the argument of the function that that are declared as constant.
    C.
    Both A and B.
    D.
    We cannot use the constant while defining the function.

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Which of the following statement is correct?

  6. A.
    Overloaded functions can have at most one default argument.
    B.
    An overloaded function cannot have default argument.
    C.
    All arguments of an overloaded function can be default.
    D.
    A function if overloaded more than once cannot have default argument.

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which of the following statement is correct?

  8. A.
    Two functions having same number of argument, order and type of argument can be overloaded if both functions do not have any default argument.
    B.
    Overloaded function must have default arguments.
    C.
    Overloaded function must have default arguments starting from the left of argument list.
    D.
    A function can be overloaded more than once.

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which of the following statement will be correct if the function has three arguments passed to it?

  10. A.
    The trailing argument will be the default argument.
    B.
    The first argument will be the default argument.
    C.
    The middle argument will be the default argument.
    D.
    All the argument will be the default argument.

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which of the following statement is incorrect?

  12. A.
    Default arguments can be provided for pointers to functions.
    B.
    A function can have all its arguments as default.
    C.
    Default argument cannot be provided for pointers to functions.
    D.
    A default argument cannot be redefined in later declaration.

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Which of the following statement is correct?

  14. A.
    Constructors can have default parameters.
    B.
    Constructors cannot have default parameters.
    C.
    Constructors cannot have more than one default parameter.
    D.
    Constructors can have at most five default parameters.

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of the following function / type of function cannot be overloaded?

  16. A.
    Member function
    B.
    Static function
    C.
    Virtual function
    D.
    Both B and C

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following function declaration is/are incorrect?

  18. A.
    int Sum(int a, int b = 2, int c = 3);
    B.
    int Sum(int a = 5, int b);
    C.
    int Sum(int a = 0, int b, int c = 3);
    D.
    Both B and C are incorrect.
    E.
    All are correct.

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Which of the following statement is incorrect?

  20. A.
    The default value for an argument can be a global constant.
    B.
    The default arguments are given in the function prototype.
    C.
    Compiler uses the prototype information to build a call, not the function definition.
    D.
    The default arguments are given in the function prototype and should be repeated in the function definition.

    View Answer

    Workspace

    Discuss Discuss in Forum