[Gambas-user] Struct with Array Field
Brian G
brian at westwoodsvcs.com
Mon Apr 10 07:26:47 CEST 2023
As a point here strings are empty no initialized. If you actually look at the structure after creation a string is in fact a null pointer till a value is assigned to it.
Look for your self
--
Thanks
Brian G Friday, 07 April 2023, 10:09AM -07:00 from T Lee Davidson t.lee.davidson at gmail.com :
>On 4/6/23 17:45, Jussi Lahtinen wrote:
>
>> In c terms which structure are interface for, strings and arrays are just pointer that are not initialized to a value until
>> something is assigned to them.
>>
>> When you do a mstrct = new mystruct it creates the structure with null pointers for those fields.
>
>[snip]
>
> The topic was *objects *inside structure. They have only null pointers. Variables are valid without further actions.
> C does not have "new", but he was referring to the similar things that need to be done in C.
>
> Jussi
>
>Yes, the original topic was arrays (objects) in a structure. To help clarify for the OP, I gave examples of what did or did not
>need to be explicitly initialized in a structure. Brian's response was to make a false statement which, to help prevent
>confusion, needed to be corrected.
>
>The statement, "When you do a mstrct = new mystruct it creates the structure with null pointers for those fields," does not
>refer to what happens in C. And, "those fields," obviously refers to "strings and arrays". As I explained, the strings would be
>automatically initialized, but the arrays would not.
>
>Is there anything incorrect about the following statement?
>Simple native datatypes (such as String, Integer, Boolean) will be automatically initialized. But, objects (such as String[],
>Integer[], Boolean[]), which are objects of classes and have properties and methods, must be initialized with the NEW keyword.
>
>
>--
>Lee
>
>
>----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230410/828c9140/attachment.htm>
More information about the User
mailing list