Question
1.
#include
2.
using namespace std;
3.
class myclass
4.
{
5.
public:
6.
int i;
7.
myclass *operator->()
8.
{return this;}
9.
};
10.
int main()
11.
{
12.
myclass ob;
13.
ob->i = 10;
14.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
class myclass
4.
{
5.
public:
6.
int i;
7.
myclass *operator->()
8.
{return this;}
9.
};
10.
int main()
11.
{
12.
myclass ob;
13.
ob->i = 10;
14.
cout
Answer: Option A
Was this answer helpful ?
In this program, -> operator is used to describe the member of the class and so we are getting this output.
Output:
$ g++ char4.cpp
$ a.out
10 10
Was this answer helpful ?
More Questions on This Topic :
Question 4.
How to declare operator function?
....
Question 6.
Pick the other name of operator function.
....
Submit Solution