new.bmx 356 B

123456789101112131415161718192021222324252627
  1. Rem
  2. New creates a BlitzMax variable of the Type specified.
  3. End Rem
  4. Type MyType
  5. Field a,b,c
  6. End Type
  7. Local t:MyType
  8. t=New MyType
  9. t.a=20
  10. print t.a
  11. ' if a new method is defined for the type it will also be called
  12. Type MyClass
  13. Field a,b,c
  14. Method New()
  15. print "Constructor invoked!"
  16. a=10
  17. End Method
  18. End Type
  19. Local c:MyClass
  20. c=new MyClass
  21. print c.a