logo

CuriousTab

CuriousTab

References problems


  • 1. Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    int main()
    {
        int m = 2, n = 6;
        int &x = m++;
        int &y = n++;
        m = x++; 
        x = m++;
        n = y++;
        y = n++;
        cout<< m << " " << n; 
        return 0; 
    }

  • Options
  • A. The program will print output 3 7.
  • B. The program will print output 4 8.
  • C. The program will print output 5 9.
  • D. The program will print output 6 10.
  • E. It will result in a compile time error.
  • Discuss
  • 2. Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    class Tab
    {
        int x, y; 
        public:
        Tab(int x, int y)
        {
            this->x = x;
            this->y = y;
        }
        void Display()
        {
            cout<< x << " " << y;
        }
    };
    int main()
    {
        int x = 50;
        int &y = x ;
        Tab b(y, x);
        return 0; 
    }

  • Options
  • A. The program will print the output 50 50.
  • B. The program will print the two garbage values.
  • C. It will result in a compile time error.
  • D. The program will print nothing.
  • Discuss
  • 3. Which of the following statements is correct?

    1. A reference is not a constant pointer.
    2. A referenced is automatically de-referenced.

  • Options
  • A. Only 1 is correct.
  • B. Only 2 is correct.
  • C. Both 1 and 2 are correct.
  • D. Both 1 and 2 are incorrect.
  • Discuss

First 2 3 4 5