[Gambas-user] How to use a STRUCTURE...

Demosthenes Koptsis demosthenesk at ...626...
Tue Jan 4 10:59:35 CET 2011


In docs there is about structures
http://gambasdoc.org/help/cat/structdecl?v3

A structure is exactly like a class that would have only public
variables.

i made an example for usage of STRUCTURES after declaration.
i made this example because i couldn't find one in wiki and i had to
consult c++ help about usage of STRUCTURES.

So i think this makes things more easy.

Is this example correct? If it is it would be nice to add it in wiki
after declaration of struct.

--------------------
' Gambas module file

Public Struct Product
  Weight As Integer
  Price As Float
End Struct

Public apple As New Product


Public Sub Main()
  
  Dim banana As New Product
  
  apple.Price = 12.34
  apple.Weight = 23 
  
  banana.Price = 20.54
  banana.Weight = 16
  
  Print "The apple is weight:"; apple.Weight
  Print "The apple costs:"; apple.Price
  Print "The banana is weight"; banana.Weight
  Print "The banana costs:"; banana.Price
  

End
--------------------


-- 
Regards,
Demosthenes Koptsis.






More information about the User mailing list