Functions


  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Example
    {
    int value1, value2, value3;
    public:
    int get()
    {
    value1 = 100;
    value2 = 350;
    value3 = 450;
    }
    friend float Average(Example obj);
    };
    float Average(Example obj)
    {
    return float(obj.value1 + obj.value2 + obj.value3) / 3;
    }
    int main()
    {
    Example object;
    object.get();
    cout << Average(object);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In this program, We are finding the Average value by declaring the function Average as a friend of class base.


  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Example
    {
    private:
    int p, q;
    public:
    void test()
    {
    p = 150;
    q = 250;
    }
    friend int Calculate(Example Exmp1);
    };
    int Calculate(Example Exmp1)
    {
    return int(Exmp1.p + Exmp1.q) - 5;
    }
    int main()
    {
    Example obj;
    obj.test();
    cout << Calculate(obj);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this program, we are finding a value from the given function by using the friend for Calculate function.



  1. What is the use of function call operator?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    overloading the objects


  1. Pick out the correct statement.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    virtual functions does not give the ability to rewrite a templated function



  1. What will happen when the function call operator is overloaded?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    It will modifies how the operator is to be interpreted when applied to objects of a given type.