A
A
Anton Savchenko2015-04-04 19:34:54
Delphi
Anton Savchenko, 2015-04-04 19:34:54

How to pass a dynamic array by value to a function in Delphi?

If you pass a two-dimensional dynamic array by value, i.e.:

type
    massive=array of array of integer;
........................................
function way(matrix:massive):boolean;

then it is as a result of the execution of the function, in the original program it still changes. How to be?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Z
zed, 2015-04-04
@Lapital

Change the function declaration to:
And inside the function, copy the array into a local variable and work with it already.

V
Vitaly Vitrenko, 2015-04-04
@Vestail

Long strings and dynamic arrays in Delphi .

O
OvLab, 2015-04-04
@OvLab

Do what the compiler does for us when we pass strings by value: create a local variable and copy the data there. And work with them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question