Inheriting a Global variable - One for all?

BlitzMax Forums/BlitzMax Beginners Area/Inheriting a Global variable - One for all?

Gabriel(Posted 2006) [#1]
Sorry, it's been a while since I used BMax, and playing with C# has just left me muddling up BMax and C#.

When you have an Abstract Type which has a Global in it, and then have three other types which extend that base type.. there is one Global variable shared between all three derived types, right? If I want a global variable in each type, separate from the others, I have to put it in each, and not try to inherit it, right?


Dreamora(Posted 2006) [#2]
correct :-)


tonyg(Posted 2006) [#3]
Gab, have you got a phobia of testing things out? ;)
Type t1 Abstract
  Global x=5
End Type
Type t2 Extends t1
  Function print_it()
     Print x
  End Function
End Type
Type t3 Extends t1
  Global x=10
  Function print_it()
    Print x
  End Function
End Type
t2.print_it()
t3.print_it()



Gabriel(Posted 2006) [#4]
Thanks guys.

No phobia, but also no access to BlitzMax two or three days a week, when I'm not at home. No IRC client either, so no asking my stupid questions there either. So sorry if I'm a bit of a pain in the arse with questions.


tonyg(Posted 2006) [#5]
It's not a problem and don't take it the wrong way. I just wonder why people don't try these things out (even on the 4-5 days a week you have access to Bmax) :)