|
Record Parameter Passing in C++ |
Top Previous Next |
|
What is translated > Routines > Parameter types > Record Parameter Passing in C++ Passing a record by value is a special case. In Delphi, records passed by value can be modified inside a routine, but such modifications do not affect the caller. To reproduce this behavior correctly in C++, Delphi2Cpp passes the record as a constant reference, and then creates a local copy inside the routine. This approach avoids unnecessary copying at the call site while preserving Delphi’s semantics.
Example:
void Foo(const MyRecord& cparam) { MyRecord param = cparam; // Use 'param' instead of 'cparam' to allow modification }
The original parameter is renamed (to cparam) to avoid naming conflicts.
|
|
This page belongs to the Delphi2Cpp Documentation |
Delphi2Cpp home Content |