![]() |
Telelogic Rhapsody (steve huntington) | ![]() |
Topic Title: How to declare postfix increment operator? Topic Summary: Created On: 16-Jun-2005 08:31 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
As title.
|
|
![]() |
|
![]() |
|
Hi
1) Add an operation to your class (eg. "MyClass") and name it "operator++" 2) Add a single int parameter. This is not used, but must exist to differentiate this operator from the prefix increment operator 3) Set the return type to be the class that the operator belongs to (eg "MyClass") 4) Write the implementation. Rhapsody (6.0) will then generate code similar to the following: class MyClass { public : /// Postfix increment operator //## operation operator++(int) inline MyClass operator++(int not_used); }; inline MyClass MyClass: ![]() //#[ operation operator++(int) MyClass ret = *this; ++(*this); // Now need to write the prefix increment operator ![]() return ret; //#] } I hope that answer wasn't over-simplistic... Did it solve your problem? ------------------------- Simon Morrish simon.morrish@eu.panasonic.com http://panasonic.co.uk Panasonic ideas for life |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.