idiomatic D: what to use instead of pointers in constructing a tree data structure?

Paulo Pinto via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 7 07:04:23 PST 2015


On Wednesday, 7 January 2015 at 15:02:34 UTC, Laeeth Isharc wrote:
>  Not true. If you're using a tree structure, you *should* use
>> pointers.
>> Unless you're using classes, which are by-reference, in which 
>> case you
>> can just use the class as-is. :-)
>
> Thanks v much.
>
> I just came to that realization also when I stepped away.
>
> class node
> {
> 	string name;
> 	node ref;
> }
>
> what's wrong with the code above ?  i get an error no 
> identifier for declarator node.  (I have not used classes much, 
> since structs often seem to be enough for what I need to do 
> mostly).

ref is a reserved keyword.

--
Paulo


More information about the Digitalmars-d-learn mailing list