C++ Operator Overloading Question:
Download Questions PDF

What is the output of this program?

#include <iostream>
using namespace std;
int main()
{
double a = 21.09399;
float b = 10.20;
int c ;
c = (int) a;
cout << c ;
c = (int) b;
cout << c ;
return 0;
}
a) 2110
b) 1210
c) 21
d) None of the mentioned

Answer:

a) 2110

Download C++ Operator Overloading Interview Questions And Answers PDF

Previous QuestionNext Question
What is the output of this program?

#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) None of the mentioned
How types are there in user defined conversion?
a) 1
b) 2
c) 3
d) 4