adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    class numbers
    {
        private:
        int m_nValues[10];
        public:
        int& operator[] (const int nValue);
    };
    int& numbers::operator[](const int nValue)
    {
        return m_nValues[nValue];
    }
    int main()
    {
        numbers N;
        N[5] = 4;
        cout <<  N[5];
        return 0;
    }

a.

5

b.

4

c.

3

d.

6

Answer: (b).4

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?