>  Docs Center  >  IDL Reference  >  Object-Oriented Programming  >  IDL_Object::_overloadPostIncrementCopy



The IDL_Object::_overloadPostIncrementCopy function method defines the behavior when the increment (++) or decrement (––) operator is used as part of an assignment statement.

There are two different forms of the increment/decrement operators: pre-increment (++a) and post-increment (a++). If you use the increment operator by itself then there is no difference in behavior. However, if you use the increment operator as part of an assignment then there is a difference in behavior. For example:

a = 5
b = ++a  ; both a and b will now have the value 6
b = a++  ; b will have the value 6, while a becomes 7

If a is actually an overloaded object, then we will run into a problem with the post-increment operator. In this case, a will get assigned to b, and then a will be incremented by calling the _overloadPlusPlus method on a's object class. However, b will also be incremented because both a and b point to the same object.

To avoid this problem, you should implement the _overloadPostIncrementCopy method for any class which implements the _overloadPlusPlus or _overloadMinusMinus method. The _overloadPostIncrementCopy method will automatically be called before the _overloadPlusPlus or _overloadMinusMinus. The method is only called when a post-increment assignment is about to be made.

Inside your method, you should either return self (if you do not care about the post-increment difference), or you should create a clone of your object and return the new object reference. Your code is responsible for constructing the clone and ensuring that all of the object's data is copied.

If you do not implement the _overloadPostIncrementCopy method, then the default behavior is to return the self object reference.

Note: Even though the method name has the word "Increment", this same method is also called when a post-decrement assignment is performed, b = a--.


For an example of how to implement this method, see the BigInteger class in the file lib/datatypes/biginteger__define.pro in your IDL installation.


In most cases, this method is called indirectly as part of a post-increment (or decrement) assignment. When called explicitly, the syntax is:

Result = Obj->[IDL_Object::]_overloadPostIncrementCopy( )

Return Value

The return value should be an object reference that is either self or a clone of self.





Routine Signature

To overload the method for an object class, implement a method with the following signature:

FUNCTION class::_overloadPostIncrementCopy

The return value of this function should be the new object reference.

Version History



See Also

IDL_Object::_overloadMinusMinus, IDL_Object::_overloadPlusPlus, Increment/Decrement operators

© 2020 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us