Method?

BlitzMax Forums/BlitzMax Beginners Area/Method?

MRaven(Posted 2004) [#1]
The docs are quit basic at some points. Would somebody please be so kind to explain, what exactly "methods" are??

Thanks :)


Warren(Posted 2004) [#2]
Methods are functions within a type - they are unique to each object instance. They are the same thing as member functions in C++.


MRaven(Posted 2004) [#3]
Ah, thanks a thousand times. So, I use "methode" same as "function", just within a type. Have to try this, sounds promessing.


Warren(Posted 2004) [#4]
Yeah, exactly.

And, BTW, using "function" within a type is the same thing as declaring a static member function in C++.


MRaven(Posted 2004) [#5]
I don't know anything about C++, but I THINK I know what it means. :)


Warren(Posted 2004) [#6]
Static just means that you don't have to have an object instance to call the function ... you just have to have the type name.

type MyType
    function MyFunction()
    end function
end type

...

MyType.MyFunction()

It's a way to organize functions somewhat. Not REALLY all that useful but, hey, there it is...


Todd(Posted 2004) [#7]
I've found that static methods are really useful for doing initializers and such. For example:

Type Foo
   Function Create:Foo()
      F:Foo = New Foo
      F.DoInitStuff()
      Return F
   End Function

   Method DoInitStuff()
      'Whatever
   End Method
End Type

F:Foo = Foo.Create()



Warren(Posted 2004) [#8]
True. They do have their uses...