Hi,
I have an abstract class called Integrator and two child classes, EmbedRK and Rungekutta. In my main.cc what I want to do is define a variable rk as the type that I want to use (either EmbedRK and Rungekutta) depending on a config file. I have the following:
The problem is that when I compile it, it complains when I use rk that 'rk' is not defined. I use it like this:Code:const string integrator_type = config.read<string>( "Integrator" ); cout << integrator_type << endl; if ( integrator_type == "embedrk" ) { cout << "Integrator: Adaptive step RungeKutta" << endl; const double startstep = config.read<double>( "StartStep" ); cout << startstep << endl; EmbedRK rk(equation, startstep, tolerance); } else if ( integrator_type == "rungekutta" ) { cout << "Integrator: RungeKutta" << endl; Rungekutta rk(equation, tolerance); } else { cout << "Integrator not recognised .. exiting" << endl; exit(1); }
where in this case the function is declared as follows:Code:Model model_2(rk,equation);
Any help to sort this out would be great.Code:Model(const Integrator &, Equations *);
Daniel Brewer




Reply With Quote