Sail E0 Webinar
Question


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
Options:
A .  converted
B .  error
C .  run time error
D .  None of the mentioned
Answer: Option A

In this program, We casted the string to the object of the class.
Output:
$ g++ con4.cppp
$ a.out
converted



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers