what difference method and function?
BlitzMax Forums/BlitzMax Beginners Area/what difference method and function?
| ||
what difference method and function in user defined types? |
| ||
A function in a type is a function associated with all of the types, in other words, there is no functionality difference. A function cannot access fields in a type without using a variable holding a type. Methods on the other hand refer to a specific type. A popular use of functions in types is a "Create" function which creates a type from parameters and returns it. |
| ||
Methods apply directly to a single object, that is an instance of a type, while functions are more general, applying to the entire type. The main difference is that methods implicitly contain a reference to the object it's being invoked on, and thus will have immediate access to all of the objects fields. A function on the other hand will only have immediate access to a types globals and constants. |
| ||
Thank you very much. |