How should I do that? I wish I could do something like this:

graph_t myGraph;

fun_A(graph_t &myGraph) {
myGraph(array, edge_array + num_arcs, weights, num_nodes);
}

fun_B(graph_t &myGraph) {
// using myGraph to run some graph algorithm...
}


You can't invoke a constructor on an object that is already created - well, you probably can, but I seriously doubt that you want to. Instead, just return myGraph from fun_A:

graph_t fun_A()
{ return graph_t(...); }

func_B(graph_t& g)
{ ... }

main()
{
  graph_t g = fun_A();
  fun_B(g);
}

It might look like there's an unnecessary copy, but there won't be.
 
Andrew Sutton
andrew.n.sutton@gmail.com