C++ Middle front ++ And postposition ++ It's different , Specific differences , It is shown in the following code .
At the back ++ in , Add a parameter manually (int), The main purpose is to distinguish the front ++, This parameter is not used . there int It's a dumb guy .
Parameters of a function Only type No name Then this parameter is called dummy .
class A { public: A& operator++()// Front ++, The reference is returned { data +=1; return *this; }
const A operator++(int)// Postposition ++, The value is returned { A old(*this); ++(*this); // Call before ++ return
old; } // As you can see from the code , Front ++ Compared with the post ++ efficient , Do not generate temporary objects , Do not call the copy constructor int data; }; ostream&
operator<<(ostream& os,A& a) { os<<a.data<<endl; return os; } int _tmain(int
argc, _TCHAR* argv[]) { A a={1}; cout<<a;//1 A b=++a; cout<<b;//2 cout<<a;//2 A
c=a++; cout<<c;//2 cout<<a;//3 return 0; }

Technology
©2020 ioDraw All rights reserved
vue + element Secondary packaging is more flexible Select assembly react Background management configuration route and sidebar :python code , Easy to complete Snake games Advanced front end -Vue Component world html+css Realize loading animation Attack and defense world forgot—— A dazzling question ( Detailed dish chicken ) Voting mechanism of ensemble learning (Voting mechanism about ensemble learning) Three categories and six sorting algorithms -C From recruitment to resume to find a fresh university student in the company Madness theory java Study notes ---JAVA Basic grammar