0
이 코드를 고려 과부하. 이제델파이 클래스 절차는
, 나는이 일을 해요 경우
procedure TForm3.FormCreate(Sender: TObject);
begin
TForm3.GetAConn('aaa');
TForm3.GetAConn(10);
end;
I 얻을 [DCC 오류] Unit3.pas (64) : E2250이 인수로 호출 할 수있는 'GetAConn'의 더 오버로드 된 버전이 없습니다 .
Delphi XE에서 제한되는 것에 대해 뭔가를 찾지 못했습니다.
LE :이 방법으로 노력하고 있습니다 : 당신은 매개 변수 by reference을 전달하는
class procedure TForm3.GetAConn(var res: String);
begin
res := res + 'modif';
end;
class procedure TForm3.GetAConn(var res: Integer);
begin
res := res + 100;
end;
procedure TForm3.FormCreate(Sender: TObject);
var s:String;
i:Integer;
begin
s:='aaa';
TForm3.GetAConn(s);
showmessage(s);
i:=10;
TForm3.GetAConn(i);
showmessage(IntToStr(i))
end;
+1. 답으로 params를 전달해야한다면 작동하지 않을 수 있습니까? – RBA
정수도 수정되지 않습니다. 그것을'const'로 전달할 수도 있습니다. –
@David : 그건 사실이지만 const 정수를 전달하는 것은 델파이 관용적이지 않습니다. 어쩌면 그 관용구를 바꿀 때가되었습니다. :-) –