Difference between a method and a function
BlitzMax Forums/BlitzMax Beginners Area/Difference between a method and a function
| ||
Serrious coolness being able to assign functions to types. I can see lots of uses for that. However, I am trying to figure out what is the difference between a method and a function inside of a type... I would use the search function to see if this has been asked before, but the search engine is down :( |
| ||
This thread should answer your question : http://www.codersworkshop.com/viewpost.php?id=16366 |
| ||
Well, Global and Function can be placed into a type. There is no real difference between having them in the type and outside of the type. Its just these are sort of associated with a type itself, and not an instance of it. Methods are associated with a specific type because they can use fields of the type without using a handle in the syntax. popular usage: Type Car Global List:TList=new TList Field Speed# Method Gas() Speed=Speed+1 End Method Function Create:Car(StartingSpeed#) local C:car=new car c.speed=startingspeed list.addlast(c) return c end function end type local c:car=car.create(5) c.gas(5) |
| ||
Having the function in a type lets you have functions of the same name within different types. They're just to help organize code as far as I can tell, which is a good enough reason for me. |
| ||
Arent Functions is a Type like Static functions in C/C++ ? |
| ||
yes they are ... they are on Class level instead instance level |