Standard struct constructors for the heap?

bearophile bearophileHUGS at lycos.com
Wed May 16 16:56:19 PDT 2012


> struct Node {
>     int data;
>     Node* next;
> }
> void main() {
>     Node n1 = Node(10); // OK
>     Node n2 = Node(10, null); // OK
> }

Sorry, I meant:

struct Node {
     int data;
     Node* next;
}
void main() {
     Node n1 = new Node(10); // OK
     Node n2 = new Node(10, null); // OK
}

Bye,
bearophile


More information about the Digitalmars-d mailing list