背景1
var text:String;
text:='hello';
myFunc(text);
Run Code Online (Sandbox Code Playgroud)
上下文2
function myFunc(mytext:String);
var textcopy:String;
begin
textcopy:=mytext;
end;
Run Code Online (Sandbox Code Playgroud)
myFunc从Context1调用Context2,局部变量mytext指向Context2之外的内存?或者在mytext范围内有自己的内存空间,并用相同的内容填充/复制text?我可能遗漏了一些非常基本的东西,因为我收到了一个access violation错误.
有没有办法明确指定一个函数是应该通过引用还是通过值接收参数,然后像C一样复制?我不确定我是怎么做的.