comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: array of pointers inside a structure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: array of pointers inside a structure [message #44360 is a reply to message #44359] Fri, 10 June 2005 11:16 Go to previous message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
Francois L. wrote:
> Hello,
>
> I am defining a structure:
>
>> a = 5
>> struct = {A:a, B:intarr(a),C:ptrarr(a)}
>
>
> Further, I want the first element of the array of pointers (C[0]) to be an
> array of 5x5 elements.
>
> How do I create it ?
>
> Thank you,
>
> Fran�ois Leduc
>
>

struct = {A:a, B:intarr(a),C:ptrarr(a)}

'struct' is a STRUCT.
'struct.c' is an array of pointers.
'struct.c[0]' is the first element of the array of pointer.

struct.c[0] = PTR_NEW( INTARR(5,5) ) Now the first element of the
pointer array (a pointer), points to an integer array.

IDL> a=5
IDL> struct = {A:a, B:intarr(a),C:ptrarr(a)}
IDL> struct.c[0] = PTR_NEW( INTARR(5,5) )
IDL> help, struct.c[0]
<Expression> POINTER = <PtrHeapVar2>
IDL> help, *struct.c[0]
<PtrHeapVar2> INT = Array[5, 5]
IDL>

Also you can create a intarr variable and point c[0] to it:

m = INTARR(5,5)
struct.c[0] = PTR_NEW(m)

But remember that PTR_NEW makes a copy of your data into the HEAP
memory. The /NO_COPY keyword creates a copy into HEAP memory and then
undefines the original variable.


--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
[Message index]
 
Read Message
Read Message
Previous Topic: array of pointers inside a structure
Next Topic: Need advice about inheritance

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 14:10:18 PDT 2025

Total time taken to generate the page: 1.04252 seconds