[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ProgSoc] New struct in C++
On Sat, Oct 16, 2004 at 03:50:48PM +1000, Matthew Beauregard wrote:
> I hate to ask what should be a simple question, but in a C++ program
> I'm working on I have:
>
> gsl_odeiv_system sys = {func, jac, n.m_de.m_num_vars, &(n.m_de)};
> n.m_sys = &sys;
>
> This will not do because I need sys allocated onto the heap. It'd be
> sufficient to do
>
> n.m_sys = {func, jac, n.m_de.m_num_vars, &(n.m_de)};
>
> because n won't fall out of scope, but that statement won't compile.
> Everything I know about gsl_odeiv_system is at
> <http://www.lsw.uni-heidelberg.de/manuals/gsl-ref-html/gsl-ref_24.html#IDX1679>.
> I suppose it must be a struct because GSL is a C library, but I don't
> know what the member names are so I can't initialise it in pieces.
> What's the solution?
You can do the assignment via a function. eg:
gsl_odeiv_system assign_gsl_odeiv_system( int (* function) (...) func,
int (*function) (...) jac,
size_t dimension m_num_vars,
void * params m_de)
{
gsl_odeiv_system auto_sys={func, jac, m_num_vars, m_de};
return auto_sys;
}
Then the following should work:
n.m_sys = assign_gsl_odeiv_system(func, jac, n.m_de.m_num_vars, &(n.m_de));
Richard.
-
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to progsoc-request@xxxxxxxxxxxxxxxxxxx
If you are having trouble, ask owner-progsoc@xxxxxxxxxxxxxxxxxx for help.