operator++() 和operator++(int)

    xiaoxiao2022-07-14  155

    #include <iostream> using namespace std; class A { public: int a; public: A& operator++() { cout<<"A& operator++()"<<endl; a=a+1; return *this; } A operator++(int) { cout<<"A operator++(int)"<<endl; A b=*this; a=a+1; return b; } }; int _tmain(int argc, _TCHAR* argv[]) { A test; test.a=12; test++; ++test; cout<<test.a<<endl; system("pause"); } A operator++(int) A& operator++() 14

     原网址:https://www.cnblogs.com/sklww/p/3709883.html

    (完)

    最新回复(0)