-
What is the output of this program?
#include <iostream&f=gt;
using namespace std;
class Num
{
private:
int Values[15];
public:
int& operator[] (const int Val);
};
int& Num::operator[](const int Val)
{
return Values[Val];
}
int main()
{
Num Object;
Object[10] = 6;
cout << Object[10];
return 0;
}
-
- 15
- 10
- 6
- Compilation Error
- None of these
Correct Option: C
In this program, We are getting the values and returning it by overloading the subscript operator.