Operators


  1. What is the return type of the conversion operator?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Conversion operator doesn’t have any return type not even void.


  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Example
    {
    public:
    Example(int k) : num_k(k) { }
    public:
    int operator()(int k = 0) const
    {
    return num_k + k;
    }
    operator int () const
    {
    return num_k;
    }
    private:
    int num_k;
    friend int g(const Example&);
    };
    int fun(char Z)
    {
    return Z;
    }
    int main()
    {
    Example fun(6);
    cout << fun(5);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In this program, we are adding its value with it itself, So only we got the output as 11.



  1. How many parameters does a conversion operator may take?









  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    0 parameters does a conversion operator may take.


  1. Why we use the “dynamic_cast” type conversion?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    It is used to check that operators and operands are compatible after conversion.



  1. Operator overloading is











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Operator overloading is the way adding operation to the existing operators.