[Assorted-commits] SF.net SVN: assorted:[1153] sandbox/trunk/src/cc/operators.cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-01-31 08:13:01
|
Revision: 1153 http://assorted.svn.sourceforge.net/assorted/?rev=1153&view=rev Author: yangzhang Date: 2009-01-31 08:12:50 +0000 (Sat, 31 Jan 2009) Log Message: ----------- added operator demo Added Paths: ----------- sandbox/trunk/src/cc/operators.cc Added: sandbox/trunk/src/cc/operators.cc =================================================================== --- sandbox/trunk/src/cc/operators.cc (rev 0) +++ sandbox/trunk/src/cc/operators.cc 2009-01-31 08:12:50 UTC (rev 1153) @@ -0,0 +1,20 @@ +#include <iostream> +using namespace std; + +class c +{ +public: + c& operator++() { cout << "++x" << endl; return *this; } + c operator++(int) { cout << "x++" << endl; return *this; } + c& operator--() { cout << "--x" << endl; return *this; } + c operator--(int) { cout << "x--" << endl; return *this; } +}; + +int main() { + c c; + c++; + ++c; + c--; + --c; + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |