1.

What is the output of this program?
#include <iostream> 
using namespace std;
class Example
{
public:
int p;
Example(int num = 0) : p(num) {};
int& operator[](int num)
{
cout << "Interview " ;
return p;
}
int operator[](int num) const
{
cout << "Mania" ;
return p;
}
};
void foo(const Example& n)
{
int Res = n[2];
}
int main()
{
Example n(7);
n[3] = 8;
int Res = n[2];
foo(n);
return 0;
}

A. Interview Interview Mania
B. Interview Mania
C. Mania
D. Compilation Error
E. None of these
Answer» B. Interview Mania


Discussion

No Comment Found

Related MCQs