[fpc-pascal] Re: Converting code from C++ to FP....

Bo Berglund bo.berglund at gmail.com
Sat Mar 19 13:03:42 CET 2011

On Sat, 19 Mar 2011 08:30:45 +0100, Aleksa Todorovic
<alexione at gmail.com> wrote:

>On Sat, Mar 19, 2011 at 06:07, Bo Berglund <bo.berglund at gmail.com> wrote:
>> 1) The second line in the loop contains the command std::max, how can
>> that be translated? I have not found any class definition for "std"
>> with a method "max"....
>There is function Max in unit Math, so you could say:
>jBegin := Max(k-band, 1);
>> 2) The parameter into the function is a pointer *A of type double. To
>> me that indicates a value of some kind, but in the code it suddenly
>> seems to appear as an array with indexing. What would be the proper
>> pascal translation of this?
>Indeed. C doesn't actually have difference between pointer to some
>data and arrays. You could use open array:
>procedure Decompose(var A: array of double);

Thanks for the information!
Now I have found another very strange construct:

void ForwardModel::SetMixedBoundaryCondition(const int iElec, 
   const double* SX0,
   const double* SY0,
   const double* SZ0,
   double* SX,
   double* SY,
   double* SZ)

Now it seems like the variable type declaration itself is a

Instead of double *Name it is double* Name. What is the difference?
It is still being used as an array:
          SX[n1] = SX0[n1] * (1.0 - w1);

Does C++ allow any placement of the * operator with the same meaning?

And what does const double* mean? Pointer to some object but not
allowed to change that object????

Having programmed Delphi for 16 years this is hard to wrap ones head
around. :-(

Bo Berglund
Developer in Sweden

More information about the fpc-pascal mailing list