Write a program to convert the class to basic(data type).
#include<iostream> using namespace std; class A { private: int x,y; public: A():x(34),y(53){} operator int() { cout << "type conversion function" << endl; return (x + y); } }; int main() { A ob; int ans; ans = ob; cout << "sum = " << ans << endl; return 0; }
Output
type conversion function sum = 87