PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Class inheritance of structures
Class inheritance of structures
Débuté par DerekT, 21 aoû. 2014 16:27 - 4 réponses
Posté le 21 août 2014 - 16:27
I have 2 classes - CLASS1, CLASS2
CLASS2 inherits CLASS1

CLASS1 contains a definition of a Structure = STRecord

I need to be able to declare a variable for this structure in CLASS2 in order that I can link controls in my window (1 only, multiple planes)

If I use LSTRecord is STRECORD I get an error stating that STRecord is unknown but if I use LSTRecord is CLASS1.STRecord then this is accepted.

Is this the correct coding for this type of scenario ?
Posté le 21 août 2014 - 19:12
Hi DerekT,

Yes this is correct coding. The structure is declared in the "namespace" Class1 and you want to use that one. You could have a structure of the same name (but different) in ClassX and then be able to declare two variables: a is Class1.Struct1; b is ClassX.Struct1 and this would work.

In fact, when structures, constants and enums (etc.) are declared in a Class, you must always prefix with the namespace. When done in collections, sometimes you must prefix it with the collection name, some other times no.

Best regards,
Alexandre Leclerc
Posté le 21 août 2014 - 19:43
Depending on your situation your could replace the structure with a class. This way you can share it.
Posté le 22 août 2014 - 10:08
Alexandre
Thank you for confirming.
I have no idea what a 'collection' would be in this context but I am looking into it.

@Pim - Thankyou
Posté le 22 août 2014 - 14:10
Hi DerekT,

You are welcomed. Also, about the "Collection", sorry about that: in English it is called "Set of procedures" (<a class="ExternalLink" rel="nofollow" target="_blank" href="http://doc.windev.com/en-US/?1513003">http://doc.windev.com/en-US/&hellip;</a>). In French it is "Collection de procédures". I just used the same word in English, but it was one of those false cognates between French and English.

So you might need to specify the set of procedures' name in some cases, especially if structures with the same name exists in different set of proc.

Best regards,
Alexandre Leclerc