Question
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
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
Answer: Option D
Was this answer helpful ?
In this program, we overloading the operator[] by using subscript operator.
Output:
$ g++ sub3.cpp
$ a.out
001
Was this answer helpful ?
More Questions on This Topic :
Question 2.
Pick out the correct statement.
....
Submit Solution