inheritance problem

BlitzMax Forums/BlitzMax Beginners Area/inheritance problem

jkrankie(Posted 2006) [#1]
I'm having a little problem with inheritance. The way i see it, my enemy2 type over rides the updatePosition method, but when i have an object of type enemy and enemy2 there is some strange behavior. Can you see what i'm doing wrong

Cheers
Charlie





Dreamora(Posted 2006) [#2]
rename global to field.

Otherwise all instances of enemy and enemy2 only have 1 single version of each of those.


jkrankie(Posted 2006) [#3]
ok, thanks. i was using global because i didn't want to be able to access the attributes outside of the type. can i still do this with field? i can't seem to make them private

Cheers
Charlie


Grey Alien(Posted 2006) [#4]
you can't make fields and methods private/public as far as I know, I'd like to be wrong on this.


Dreamora(Posted 2006) [#5]
Nope, sadly you are right GA.

all information are public. If you don't want to make them public, then check the faq section, the first thread in there shows how to do it.

BUT: This will it make impossible to extend your types ... (as the implementation is the private part and thus can't be extended)


Grey Alien(Posted 2006) [#6]
thanks Dreamora. It would be useful to have private just so users of my Types don't try calling internal methods...


Beaker(Posted 2006) [#7]
You can try renaming all your private stuff with an underscore at the beginning. Works as a good reminder.


Grey Alien(Posted 2006) [#8]
Thanks, I guess the same could be applied to methods too.


Dreamora(Posted 2006) [#9]
That or simply not documenting it. There is no IDE so far that is able to parse the .i files to show undocumented stuff on a precompiled library. (and even if, you could still remove it from there, if it is not used from outside anyway)


Grey Alien(Posted 2006) [#10]
I haven't got as far as documentation ... :-/