Name: Anonymous 2011-10-15 23:44
#include <iostream>
using namespace std;
class funzies {
public:
funzies(int value) : value_(value) {}
~funzies() {}
funzies& operator++() {
value_++;
return *this;
}
funzies& operator++(int) {
++value_;
return *this;
}
funzies& operator--() {
value_--;
return *this;
}
funzies& operator--(int) {
--value_;
return *this;
}
friend ostream& operator<<(ostream& stream, funzies& self) {
return stream << self.value_;
}
private:
int value_;
};
int main(int argc, char** argv) {
funzies funfun(6);
cout << funfun << endl;
cout << ++funfun++ << endl;
cout << ++++funfun++++ << endl;
cout << ++--funfun--++ << endl;
cout << --++--++--funfun--++--++-- << endl;
return 0;
}output:
6
8
12
12
10