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

Mayost Sharon sharon at 455.co.il
Fri Apr 21 05:53:16 CEST 2023


---------- Original Message -----------
From: Jussi Lahtinen <jussi.lahtinen at gmail.com>
To: Gambas Mailing List <user at lists.gambas-basic.org>
Sent: Fri, 21 Apr 2023 00:57:52 +0300
Subject: Re: [Gambas-user] protected for a variable inherited from a class

> Here is a way to do what you want, but I don't really like it. See the
> attachment.
> 
> Jussi
> 
> On Thu, Apr 20, 2023 at 11:36 PM Jussi Lahtinen <jussi.lahtinen at gmail.com>
> wrote:
> 
> > No, sorry I messed up. Inherent private variables/subs/functions can only
> > be overridden, not accessed.
> > If class1 is merely a base class, then you can prevent its usage with
> > "create private". But not just a single variable/method.
> >
> >
> > Jussi
> >
> > On Thu, Apr 20, 2023 at 10:25 PM Mayost Sharon <sharon at 455.co.il> wrote:
> >
> >> Hello
> >>
> >> Is there a way to access a variable inherited from class1
> >> but
> >> that it will not be visible to other non-inherited classes
> >>
> >> something like this:
> >> https://www.w3schools.com/cpp/cpp_inheritance_access.asp
> >>
> >> I tried to think maybe with: STATIC PRIVATE
> >> But it's not working
> >>
> >>
> >> Many thanks to everyone
> >>
> >> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> >>
> >
------- End of Original Message -------

Hello
Thank you

I learned another new thing from your example, thanks

but

1. You seem to be what you were seemingly to achieve through:
Static Public Function GetPrivate() As Integer
(that doesn't work either)

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

Many thanks


More information about the User mailing list