[Gambas-user] CLASS inherits from CLASS causes OUT OF BOUNDS (#22)
Mayost Sharon
sharon at 455.co.il
Tue Apr 18 08:22:30 CEST 2023
---------- Original Message -----------
From: Bruce Steers <bsteers4 at gmail.com>
To: Gambas Mailing List <user at lists.gambas-basic.org>
Sent: Tue, 18 Apr 2023 00:31:18 +0100
Subject: Re: [Gambas-user] CLASS inherits from CLASS causes OUT OF BOUNDS (#22)
> On Mon, 17 Apr 2023 at 15:45, Mayost Sharon <sharon at 455.co.il> wrote:
>
> > Hello
> >
> > I am trying to create a class within a class that the second class
> > inherits from the first class
> >
> > when i run
> > The GAMBAS IDE comes out
> > with an error
> > OUT OF BOUNDS (#22)
> >
> > Is it my mistake?
> >
>
> Yep
> your inherited class makes a New object of itself recursively because of
> the inheritance.
> Class2 inherits class1
> and class1 has
> Private $prop2 As New Class2
> and Class2 inherits class1
> and class1 has
> Private $prop2 As New Class2
> and Class2 inherits class1
> and class1 has
> Private $prop2 As New Class2
> See where that's going.
>
> > Attached is the code I tried to run
>
> What exactly are you trying to do?
>
> Thank you
------- End of Original Message -------
Thanks
I'm just trying to learn what can be done with classes
I wanted to get to
class1.class2.test()
And through class2 I want to change a variable that is in class1
So in this discussion:
https://lists.gambas-basic.org/pipermail/user/2023-April/079119.html
They said there are two possibilities:
1. Make the variable found in class1 with a static declaration
But the problem is that when I register class1. It will also show me this variable that I don't want it to be public
2. Make class2 inherit from class1 and then I can access from class2 to class1
And when I try it gives the error of: OUT OF BOUNDS
More information about the User
mailing list