C++ Overloading Conversion Operators
问题 I am trying to have a class that allows implicit casting to certain built in types, like unsigned long int and since I'm trying to do this as correct as possible (this is my first important project in C++), I have hit a strange issue regarding const correctness: This works: #include <iostream> class CustomizedInt { private: int data; public: CustomizedInt(); CustomizedInt(int input); operator unsigned long int () const { unsigned long int output; output = (unsigned long int)data; return