Browse - Programming Tips - How do I declare the pre and post increment operators?

Date: 2011apr29
Language: C++

Q.  How do I declare the pre and post increment operators?

A.  The post increment has a parameter of int and pre is has no parameters.
For example:

class MyClass { int i; public: void operator++() // PRE-increment { ++i; } void operator++(const int) // POST-increment { i++; } };