"Static" means: - For a variable, that the variable is stored in the class, not in any object. So there is only one such variable. Its value does not depend on the object.
- For a method (or a property), that the method cannot use any non-static symbol (ME is NULL). - For a constant, nothing, as a constant is always static (as its value cannot change). I hope it will be clear for you! Regards, -- Benoît Minisini I am interesting in STATIC too. I think a real example will be a better explanation. Create new console project and put the next text in MMain.module |' Gambas module file Public Sub Main() 'Use <<AS NEW CUnit>> instead <<AS CUnit>> 'to activate constructor Dim Unit1, Unit2 As New CUnit Dim Unit3, Unit4 As New CUnit 'Theese objects are not created yet? Dim Unit5, Unit6 As CUnit 'We have 4 objects created CUnit.HowManyUnits() 'Uncomment last two lines and see '"Unexpected DIM as MMain.module:20" 'In C++ that will not cause an error 'Dim Unit7 As CUnit 'CUnit.HowManyUnits() End| And create new class "CUnit" with text |' Gambas class file Static Private NumberOfUnits As Integer = 0 'constructor Public Sub _new() NumberOfUnits += 1 Print "New Unit was created" End Static Public Sub HowManyUnits() Print "There are "; NumberOfUnits; " objects of class 'CUnit'" End| Output in console: |New Unit was created New Unit was created New Unit was created New Unit was created There are 4 objects of class 'CUnit'| Now comment all "DIM ..." lines and run. Output in console without any error: |There are 0 objects of class 'CUnit'|This code is not clear to me. What the difference between "PUBLIC SUB _new()" and "PUBLIC SUB New()" ? And why I can't create objects of class CUnits after calling CUnit.HowManyUnits()?
OOP_3_STATIC-0.0.1.tar.gz
Description: GNU Zip compressed data
------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user