• ( 2 ) In case of operator overloading, operator function must be ______ .
      1. Static member functions
      2. Non- static member functions
      3. Friend Functions

    • 1) Only 2
    • 2) Only 1, 3
    • 3) Only 2 , 3
    • 4) All 1 , 2, 3
    • Discussion in forum
      Answer : 3) Only 2 , 3
      Solution :








      discussion


      Answer : 3) Only 2 , 3

    • ( 3 ) To overload an operator__________ keyword must be used along with the operator to be overloaded.

    • 1) Over
    • 2) Overload
    • 3) Void
    • 4) Operator
    • Discussion in forum
      Answer : 4) Operator
      Solution :








      discussion


      Answer : 4) Operator

    • ( 5 ) The order in which operands are evaluated in an expression is predictable if the operator is;

    • 1) *
    • 2) +
    • 3) %
    • 4) &&
    • Discussion in forum
      Answer : 4) &&
      Solution :








      discussion


      Answer : 4) &&

    • ( 6 ) Which of the following operators can be overloaded?

    • 1) . (dot or member access operator)
    • 2) & ( address-of operator)
    • 3) size of operator
    • 4) ?: (conditional opeator)
    • Discussion in forum
      Answer : 2) & ( address-of operator)
      Solution :








      discussion


      Answer : 2) & ( address-of operator)

    • ( 7 ) Overloading a postfix increment operator by means of a member function takes

    • 1) no argument
    • 2) one argument
    • 3) two arguments
    • 4) three arguments
    • Discussion in forum
      Answer : 1) no argument
      Solution :








      discussion


      Answer : 1) no argument

    • ( 8 ) When overloading unary operators using Friend function,it requires_____ argument/s.

    • 1) Zero
    • 2) One
    • 3) Two
    • 4) None of these
    • Discussion in forum
      Answer : 2) One
      Solution : We have to declare the operator function by using operator, operator sign. Example “operator +” where operator is a keyword and + is the symbol need to be overloaded.








      discussion


      Answer : 2) One

    • ( 9 ) How to declare operator function?

    • 1) operator operator sign
    • 2) operator
    • 3) operator sign
    • 4) None of these
    • Discussion in forum
      Answer : 1) operator operator sign
      Solution :








      discussion


      Answer : 1) operator operator sign

    • ( 10 ) Predict the output
      #include
      using namespace std;
      class A
      {
      int i;
      public:
      A(int ii = 0) : i(ii) {}
      void show()
      {
      cout << i << endl;
      }
      };
      class B
      {
      int x;
      public:
      B(int xx) : x(xx) {}
      operator A() const { return A(x);
      }
      };
      void g(A a)
      {
      a.show();
      }
      int main()
      {
      B b(10);
      g(b);
      g(20);
      return 0;
      }

    • 1) Compiler Erro
    • 2) 10 20
    • 3) 20 20
    • 4) 10 10
    • Discussion in forum
      Answer : 2) 10 20
      Solution :








      discussion


      Answer : 2) 10 20





Top