Overriding Create()

BlitzMax Forums/BlitzMax Beginners Area/Overriding Create()

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Can everyone Please please please Learn the difference between Override, and overload.

@Grey When you "Override a function with .. different params" That is overloading

(edit) @Dream. Took this out cos it looked silly as you have just posted

I spent yesturday trying to find out how to do that function create thing in the first post (Answer: Use a create Method, and it all works), This was getting me more and more frustrated. And anyone who followed the Casting thread later, will see this was asabated by be useing realese builds all day. (Im blameing ZIGGY for that ;)

What didnot help was

1) People Telling me I couldnt do somthing that I hadnt done, and saying thats why it didnt work
2) Me knowing that because Id written it, it must be right, and Blitz wrong.
3)People saying you need to use this, "######", then posting later that it still wouldnt work (you know who you are)

OverRide: When you have a Function/Method with the same "FootPrint" as one earler in the class tree.
Type AType
..
Method:Int Draw ()
Return True
End Method

Type BType Extends AType
..
Method:Int Draw ()
Return True
End Method


As we can see The first Type (AType) has a method Draw, which takes no parameters, and returns an INT. We then in the extended Type (BType) also have a method Draw, which agian takes no parameters and returns INT. In FACT it MUST, take no parameters and return INT, because it needs to look just like origional method to the comiler.

"An overloaded declaration is a declaration that had been declared with the same name as a previously declared declaration in the same scope, except that both declarations have different types.
If you call an overloaded function name or operator, the compiler determines the most appropriate definition to use by comparing the argument types you used to call the function or operator with the parameter types specified in the definitions" <---- Just Got this From the Internet.

'THIS DOES NOT WORK
Type AType
..
Method Draw:INT ()
Return TRUE
END Method
Method Draw:Float ()
Return  True
End Method


As we can see a new method Draw:float has been added to the type. These are obviously two different Methods, because look one returns an INT, the Other a FLOAT. The DRAW method is now Overloaded, There are two draws with different footprints.
These are considered different in some compilers, (Ie ones that Overload), but not in BMAx