[Gambas-user] CLASS inherits from CLASS causes OUT OF BOUNDS (#22)
BB
adamnt42 at gmail.com
Tue Apr 18 09:59:13 CEST 2023
Inine!
On 18/4/23 5:08 pm, Mayost Sharon wrote:
> ---------- Original Message -----------
> From: BB <adamnt42 at gmail.com>
> To: user at lists.gambas-basic.org
> Sent: Tue, 18 Apr 2023 16:04:19 +0930
> Subject: Re: [Gambas-user] CLASS inherits from CLASS causes OUT OF BOUNDS (#22)
>
>
> Thank you
> I learned another new thing from your example, thanks
>
> But I want to reach something like this:
> pet.cat.name
> pet.Dog.name
A class is a blueprint for an object. "Pet" is an object built say, from
the Dog class. You can't reference a Cat from a Dog. "Pet".name here is
"Fido" you reference Pet.Name, not Pet.Dog.Name!
Try thinking like this. A blueprint for YourHouse is used by a builder
to construct your house. If you want to go to the kitchen you go to
YourHouse.Kitchen not YourHouse.blueprint.Kitchen - if you try that you
will be standing on a piece of paper. Get the drift?
> And through a Cat class want to change a variable that is in ANIMAL
When the Pet object is the cat, the Main routine sets properties in the
Animal class e.g. Pet.Name="Tiddles". There is no need to access
Pet.animal.Name because Pet(Cat) _is_ an animal!
However, if you want to set an animal property inside a cat object then
it can be done by using the Me construct. Again read
https://gambaswiki.org/wiki/doc/object-model this until your eyes bleed,
especially 3.1
>
> I will try to make a more logical sample code from TIMER so that they know what I want
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230418/aabc67bb/attachment.htm>
More information about the User
mailing list