Function() { x = 0; y = 0; } virtual double Calculation (int) = 0;// базовый virtual double Calculation(int t) производный { y = exp(t); x = 2 * exp(t); return ; } 

both x and y must be returned immediately.

  • 2
    pack them in some kind of data structure, for example std::tuple - Flowneee

1 answer 1

General options for returning multiple values ​​- through the structure or by reference.

For example, in your version you can use the standard pair structure:

 pair<double,double> Calculation(double t) { pair<double,double> result; result.first = exp(t); result.second = 2 * exp(t); return result; } 

Or by reference:

 void Calculation(double t, double& x, double& y) { y = exp(t); x = 2 * exp(t); } 

well, in the code - something like

 double x, y; obj.Calculation(3,x,y);