Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic Rhapsody (steve huntington)
Decrease font size
Increase font size
Topic Title: How to declare postfix increment operator?
Topic Summary:
Created On: 16-Jun-2005 08:31
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 16-Jun-2005 08:31
User is offline View Users Profile Print this message


Clifford Choy

Posts: 4
Joined: 6-Apr-2005

As title.
Report this to a Moderator Report this to a Moderator
 23-Jun-2005 15:03
User is offline View Users Profile Print this message


Simon Morrish

Posts: 127
Joined: 17-May-2005

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:perator++(int not_used) {
//#[ 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
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic Rhapsody forum.
There are currently 0 users logged in.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.