#include <iostream>using namespace std;class MyInt{ private: int nVal;public: MyInt( int n) { nVal = n;} int ReturnVal() { return nVal;} friend ostream & operator <<(ostream &os, MyI 展开
#include <iostream>using namespace std;class MyInt{ private: int nVal;public: MyInt( int n) { nVal = n;} int ReturnVal() { return nVal;} friend ostream & operator <<(ostream &os, MyInt &obj) { os <<obj.nVal;return os;} MyInt & operator - ( int k) { nVal -= k;return *this;} MyInt operator = (const MyInt &obj) { return MyInt(obj.nVal);}};int main (int argc, char *argv[]) { MyInt objInt(10);objInt = objInt - 2 - 1 - 3;cout <<objInt;cout <<",";objInt = objInt - 2 - 1;cout <<objInt;cout <<endl;} 收起