Confusion++
I’ll bet a hundred bucks that any entry level C++ interview or exam will somehow drift into questions about the pre and post increment operators. It’s almost become a canonical, rite of passage sort of thing. Now using the operators is one thing, overloading them for your own types is another. In C++, you write something like class X { int val; public: X() : val(0){ } X operator++() { val++; return *this; } X operator++(int) { X pX = *this; val++; return pX; }; int Value() { return val; } }; Fairly straightforward stuff – C++ uses the int … Continue reading Confusion++