On Tuesday, 3 June 2014 at 03:35:46 UTC, Chris Cain wrote:
On Tuesday, 3 June 2014 at 03:17:10 UTC, Charles Parker wrote:
...
Thanx for any help - Charlie
Well one thing is that you don't need the type parameters on the
this function. You're basically creating a templated this inside
the templated class which is not what you want.
try this:
class node(D, E) {
int nid;
D data;
E[] in_edges; // All edges for undirected graphs go
here.
E[] out_edges; // Only used by directed graphs
this(D data, int n) {
this.data = data;
nid = n;
in_edges = new E[];
out_edges = new E[];
}
Another thing is that you're missing the ! to instantiate
v
auto fee = new node!(string, u_edge)("Suck Moose", 1);
^
Chris, that was it I needed to do both things. It then complained
about trying to allocate the in_edges and out_edges arrays in the
constructor which is how I thought dynamic arrays are allocated
on the heap. I removed the 2 new statements, and both compile and
execution of my initial test worked.
Thanx - Charlie