[Gambas-user] protected for a variable inherited from a class

T Lee Davidson t.lee.davidson at gmail.com
Fri Apr 21 16:57:40 CEST 2023


On 4/20/23 23:53, Mayost Sharon wrote:
> 1. You seem to be what you were seemingly to achieve through:
> Static Public Function GetPrivate() As Integer
> (that doesn't work either)

Of course it doesn't work. The value that function returns is dynamic not static. Static and dynamic methods and variables 
cannot be mixed.


> 2. In your example, still when I register hObj1 and a period in the IDE, it completes me and shows me that there is a GetPrivate method. I'm looking for a way that it won't show it to me when I create an instance of CLASS1 but when I'm in CLASS2 which is an inheritance of CLASS1 so Inside it will be possible to access CLASS1.GetPrivate

If CLASS2 has inherited CLASS1, then it has also inherited the GetPrivate method and, therefore, it then makes no sense to 
attempt to access that method with a syntax of CLASS1.GetPrivate. If you wish to access it with that syntax, then don't inherit 
CLASS1 in CLASS2.

Now why does it matter to you what the IDE auto-completion function shows you?


-- 
Lee



More information about the User mailing list