====== C - C++ Operator Overloading - Conversion operator overloading ====== #include using namespace std; class Forgetcode { public: Forgetcode(); Forgetcode(int val); ~Forgetcode(){} int getval()const { return val; } void setval(int x) {val = x; } operator unsigned long(); private: int val; }; Forgetcode::Forgetcode():val(0) {} Forgetcode::Forgetcode(int y): val(y) {} Forgetcode::operator unsigned long() { return ( int (val) ); } int main() { Forgetcode ctr(50000000); int longvar = ctr; cout << "longvar " << longvar << std::endl; return 0; }