Article # 20, added by Geoworks, historical record
| first |
previous |
index |
next |
last |
How to pass pointers to instance data to functions.
Q: I'm writing a method for a class and I want to call a function that will operate on the instance data of an object of that class. How can I pass pself to this function so it can modify the instance data of the object? A: Although this kind of thing is discouraged because it violates most OOP paradigms, here is how you would do that: @method GenDocumentClass, MSG_GEN_DOCUMENT_MESSAGE { BadOOPFunc( pself ); } void BadOOPFunc( GenDocumentInstance * objData ) { objData->GDI_fileHandle = NullHandle; } This is a weak example of why you might want to do this, but you can see that to pass pself to a function, simply make the function parameter a type of <ClassName>Instance. So for a class called "InvListClass", I would make the function parameter type "InvListInstance". Be sure to include the * and -> since you are passing a struct by reference.