Array-initialization

Hendrik Renken funsheep at gmx.net
Thu Oct 9 11:05:01 PDT 2008


Hi,

i have a question regarding array-initialization.


consider:

struct STRUCT
{
     byte[] data;
}


STRUCT foo(byte[] myData)
{
     STRUCT* s = new STRUCT(myData);
}


do i now create a struct with an array on the heap and then drop the 
array and assign to the array-pointer the array "myData"? If yes, how 
can i avoid the creation and deletion of the array "data" in the first 
place? Am i right, that the variable "data" only holds a pointer to the 
real array?

regards,
hendrik




More information about the Digitalmars-d-learn mailing list