class MyCin{private: bool status;public: MyCin():status(true){} MyCin & operator >> (int & n) { if (!status) return *this; cin >> n; if (n == -1) status = false; return *this; } operator bool() { return status; }//类型转换函数}; 主要是bool类型转换运算符