No, private is really private.
You call a public sub which changed the private data ;)
I suggest you read the documentation at
http://gambasdoc.org/help/cat/objectmodel?v3

2012/1/7 Dmitrij Malkov <dima.malkov.rus...@gmail.com>

>
> I add a new class, child to CUnit. I named It "CUnitChild". It's code:
> ------------------------------------------
> ' Gambas class file
>
> Inherits CUnit
> ------------------------------------------
>
>
>
> And I add creation on object of this class in the middle of MMain:
> ------------------------------------------
> ' Gambas module file
>
> Public Sub Main()
>  Dim Unit1, Unit2, Unit3, Unit4 As CUnit
>  Dim i As Integer 'counter
>  Dim aUnit As New CUnit[5] 'Array
>   Dim Child1 As CUnitChild 'Inherited of CUnit
>
>  CUnit.HowManyUnits()
>  Unit1 = New CUnit
>  Unit2 = New CUnit
>  CUnit.HowManyUnits()
>  Unit3 = New CUnit
>  Unit4 = New CUnit
>  CUnit.HowManyUnits()
>
>   'trying to create and work with
>  'child class of CUnit
>  Child1 = New CUnitChild
>  CUnitChild.HowManyUnits()
>  Child1.PrintIdentification()
>
>  'creation in a cycle
>  For i = 1 To 100
>    SubForCycleCreation()
>  Next
>  CUnit.HowManyUnits()
>
>  'creation to an array
>  For i = 0 To 4
>    aUnit[i] = New CUnit
>  Next
>  CUnit.HowManyUnits()
>
>  aUnit[0].PrintIdentification()
> End
>
> Public Sub SubForCycleCreation()
>  Dim Unit5 As CUnit
>  Unit5 = New CUnit
> End
> ------------------------------------------
>
>
> The output is
> ------------------------------------------
> There are 0 objects of class 'CUnit'
> There are 2 objects of class 'CUnit'
> There are 4 objects of class 'CUnit'
> There are 5 objects of class 'CUnit'
> Identity number of the object is 5
> There are 105 objects of class 'CUnit'
> There are 110 objects of class 'CUnit'
> Identity number of the object is 106
> ------------------------------------------
>
>
> Oh my God! "PRIVATE" in Gambas3 is the same, as "Protected" in C++, because
> the existion of the object "Child1" changed the private data "Static
> Private
> NumberOfUnits" of the class "CUnit". Maybe I am wrong.
>
> How to rewrite constructor for a child class?
> How to write and test destructors?
>
> http://old.nabble.com/file/p33097604/OOP_3_STATIC-0.0.1.tar.gz
> OOP_3_STATIC-0.0.1.tar.gz
> --
> View this message in context:
> http://old.nabble.com/File-opening-dialog-and-one-more-question-tp33085420p33097604.html
> Sent from the gambas-user mailing list archive at Nabble.com.
>
>
>
> ------------------------------------------------------------------------------
> 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
>
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to