Array of pointers

Namespace rswhite4 at googlemail.com
Thu Jan 16 01:55:49 PST 2014


On Thursday, 16 January 2014 at 09:47:21 UTC, Rene Zwanenburg 
wrote:
> On Thursday, 16 January 2014 at 09:03:00 UTC, Arjan Fetahu 
> wrote:
>> On Thursday, 16 January 2014 at 09:00:18 UTC, Namespace wrote:
>>> On Thursday, 16 January 2014 at 08:55:43 UTC, Arjan Fetahu 
>>> wrote:
>>>> Hi. I started my first program in D (I have a little 
>>>> experience in c).
>>>> I wanted to create an array of pointers for creating a node 
>>>> with multiple
>>>> connections. In C you can make one directly (node 
>>>> *nedePtr[]). What is the equivalent for the D's syntax??
>>>>
>>>> Regards
>>>> Arjan
>>>
>>> node*[] nedePtr;
>>
>> Ok. Thank You!
>
> Keep in mind that, unlike in c++, D classes are reference types:
>
> class Node
> {
>     Node[] nodes; // This is valid
> }
>
> Structs are value types though, so using a struct in the above 
> example is illegal.

You mean:
----
struct Node {
     Node[] nodes;
}
----

or

----
struct Node {
     Node*[] nodes;
}
----

? Works both.

What's not working is this:
----
struct Node {
	Node node;
}
----


More information about the Digitalmars-d-learn mailing list