Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost] Create Graph in Function
From: James Thunes (j.thunes_at_[hidden])
Date: 2009-10-29 10:33:14


On Thu, Oct 29, 2009 at 8:47 AM, Jeremiah Willcock <jewillco_at_[hidden]>wrote:

> On Wed, 28 Oct 2009, James wrote:
>
> That is the issue. I agree that to manipulate the graph in the Fortran
>> portion of the code would be difficult (due the lack of a comparable data
>> type). Luckily, I don't need to modify the graph in the Fortran portion of
>> the code, I just need to allow for a c++ function to access the graph. If I
>> can define the graph as a global variable in c++ and negate the need to pass
>> the graph from the create_graph function to the modify_graph function via
>> the Fortran main routine:
>> Create_Graph.cpp -> Main.f -> Modify_Graph.cpp
>> would be great.
>>
>> Would I accomplish this as:
>> in create_graph.cpp
>> Graph& g;
>>
>> void create_graph(){
>> \\ create graph
>> }
>>
>> and in modify_graph.cpp
>> extern Graph& g;
>>
>> void modify_graph(){
>> \\...
>> }
>>
>
> The storage for the graph needs to be somewhere; making the variables of
> type Graph rather than Graph& would solve that problem.
>
>
> -- Jeremiah Willcock
>
> That worked. With the two functions as:
create_graph.cpp
   Graph g;

   void create_graph(){
   \\...
  }

and modify_graph.cpp
  extern Graph g;

   void modify_graph(){
   \\...
   }

The code compiles and runs correctly for my test case. Thanks for the help!



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net