How to declare a parameterized recursive data structure?

Philippe Sigaud via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 15 12:47:21 PDT 2014


On Fri, Aug 15, 2014 at 9:13 PM, artemav via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> :) Wow, thanks for all replies. I realized too late that should write
> "that's it".
> Hmm, It's also a good sign that D community is active.

Can I add something? ;)

You can also use a class, as they are reference types:

class node(T) {
    T data;
    node next;
}

Or use a dynamic array if you want to define a tree:

struct node(T) {
    T data;
    node[] children;
}


More information about the Digitalmars-d mailing list