Question
1.
#include
2.
#include
3.
using namespace std;
4.
class test
5.
{
6.
public:
7.
operator string ()
8.
{
9.
return "Converted";
10.
}
11.
};
12.
int main()
13.
{
14.
test t;
15.
string s = t;
16.
cout
What is the output of this program?
1.
#include
2.
#include
3.
using namespace std;
4.
class test
5.
{
6.
public:
7.
operator string ()
8.
{
9.
return "Converted";
10.
}
11.
};
12.
int main()
13.
{
14.
test t;
15.
string s = t;
16.
cout
Answer: Option A
Was this answer helpful ?
In this program, We casted the string to the object of the class.
Output:
$ g++ con4.cppp
$ a.out
converted
Was this answer helpful ?
Submit Solution