<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">How should I do that? I wish I could do something like this:<br> <br> graph_t myGraph;<br> <br> fun_A(graph_t &myGraph) {<br> myGraph(array, edge_array + num_arcs, weights, num_nodes);<br> }<br> <br> fun_B(graph_t &myGraph) {<br> // using myGraph to run some graph algorithm...<br> }<br> <br> </blockquote><div><br>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:<br><br>graph_t fun_A() <br> { return graph_t(...); }<br><br>func_B(graph_t& g)<br>{ ... }<br><br>main()<br>{<br> graph_t g = fun_A();<br> fun_B(g);<br>}<br><br>It might look like there's an unnecessary copy, but there won't be.<br> </div> </div>Andrew Sutton<br><a href="mailto:andrew.n.sutton@gmail.com">andrew.n.sutton@gmail.com</a><br>