Pick out the correct syntax of operator conversion.
How types are there in user defined conversion?
What is the output of this program?
1. #include2. using namespace std; 3. int main() 4. { 5. double a = 21.09399; 6. float b = 10.20; 7. int c ; 8. c = (int) a; 9. cout << c ; 10. c = (int) b; 11. cout << c ; 12. return 0; 13. }
What is the output of this program?
1. #include2. #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 << s << endl; 17. return 0; 18. }
What is the output of this program?
1. #include2. #include 3. using namespace std; 4. class Complex 5. { 6. private: 7. double real; 8. double imag; 9. public: 10. Complex(double r = 0.0, double i = 0.0) : real(r), imag(i) 11. {} 12. double mag() 13. { 14. return getMag(); 15. } 16. operator double () 17. { 18. return getMag(); 19. } 20. private: 21. double getMag() 22. { 23. return sqrt(real * real + imag * imag); 24. } 25. }; 26. int main() 27. { 28. Complex com(3.0, 4.0); 29. cout << com.mag(); 30. cout << com; 31. return 0 32. }