Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
class A
4.
{
5.
public:
6.
int x;
7.
A(int n = 0) : x(n) {};
8.
int& operator[](int n)
9.
{
10.
cout
Options:
A .  110
B .  111
C .  011
D .  001
Answer: Option D

In this program, we overloading the operator[] by using subscript operator.
Output:
$ g++ sub3.cpp
$ a.out
001



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers