Hi,

i've had a look with flasm, it explicitly calls A.dothis() in A.doit.
writing this.dothis() isn't possible because it's a static function --
there is no object "this" could refer to.
there is, as far as i know, nothing you can do about it except to work
around it by either cutting'n'pasting doit from A, or using a
singleton instead.

instinctively, i would agree with you and expect B.dothis to get
called when i call B.doit, though

Nope, when you call the static method, it will not change when subclassed. That is exactly as I would expect.

This is due to the fact, that static methods aren't inherited - they do not exist on instances. They only exist on the class itself. When you call a static method or refence a static variable, that path to the variable or method will be "hardcoded" in front of the name of the member and thus not change when subclassed.

I would also expect this behaviour. Consider static methods as though they existed in a totally different class. If class A refenced a method of class C, then just because A was subclassed into B, B still refers to class C - what else should it do?

--
Morten Barklund - Information Architect - Shockwaved
Gothersgade 49, 4th floor - DK-1123 Copenhagen K, Denmark
Phone: +45 7027 2227 - Fax: +45 3369 1174
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to