L
liuchong
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure BCD(var A:array of Char);
begin
//为什么这里编译通不过:
ShowMessage(IntToStr(Cardinal(A)));
end;
procedure TForm1.btn1Click(Sender: TObject);
var
A:array of Char;
begin
//这里编译可以通过:
ShowMessage(IntToStr(Cardinal(A)));
end;
问题二:
procedure ABC(A:array of Byte);
begin
end;
procedure TForm1.btn1Click(Sender: TObject);
var
A:array of Byte;
begin
ABC(A);
end;
上面在代码可以编译通过。
下面的代码不能编译:
procedure ABC(A:array of Char);
begin
end;
procedure TForm1.btn1Click(Sender: TObject);
var
A:array of Char;
begin
ABC(A);
end;
问题三:
procedure ABC(A:array of const);
begin
ShowMessage(IntToStr(Cardinal(@A[0]))+':'+IntToStr(Cardinal(@A[1]))+':'+IntToStr(Cardinal(@A[2])));
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
//array of const的内存是连续的吗?不同类型的数据怎样分配内存的?
ABC([True,3,'a']);
end;
begin
//为什么这里编译通不过:
ShowMessage(IntToStr(Cardinal(A)));
end;
procedure TForm1.btn1Click(Sender: TObject);
var
A:array of Char;
begin
//这里编译可以通过:
ShowMessage(IntToStr(Cardinal(A)));
end;
问题二:
procedure ABC(A:array of Byte);
begin
end;
procedure TForm1.btn1Click(Sender: TObject);
var
A:array of Byte;
begin
ABC(A);
end;
上面在代码可以编译通过。
下面的代码不能编译:
procedure ABC(A:array of Char);
begin
end;
procedure TForm1.btn1Click(Sender: TObject);
var
A:array of Char;
begin
ABC(A);
end;
问题三:
procedure ABC(A:array of const);
begin
ShowMessage(IntToStr(Cardinal(@A[0]))+':'+IntToStr(Cardinal(@A[1]))+':'+IntToStr(Cardinal(@A[2])));
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
//array of const的内存是连续的吗?不同类型的数据怎样分配内存的?
ABC([True,3,'a']);
end;