unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
[red]uses unit2;[/red]
{$R *.dfm}
function msg(s:string):string;
begin
form1.edit1.text:=s;
end;
end.
---------------------------unit2-------------------------------------------
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
[red]uses unit1;[/red]
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
msg('kkkkk');
end;
end.
//--------------编译无法通过,提示:---------------------------------------------
[错误] Unit2.pas(28): Invalid typecast
[致命错误] Unit1.pas(23): Could not compile used unit 'Unit2.pas'