Examveda

What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class test
{
    public:
    operator string () 
    {  
        return "Converted";
    }
};
int main()
{
    test t;
    string s = t;
    cout << s << endl;
    return 0;
}

A. converted

B. error

C. run time error

D. convertedconverted

Answer: Option A


Join The Discussion

Related Questions on Classes and Objects in C plus plus