不知那里错了,不能编译(50分)

  • 主题发起人 主题发起人 handsome1234
  • 开始时间 开始时间
H

handsome1234

Unregistered / Unconfirmed
GUEST, unregistred user!
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;

type
Thuman=class
Name:string;
end;

TStudent=class(Thuman)
SchoolName:string;
procedure ShowInf;
end;

ClassRef=class of TObject;

var
Student:array[0..1]of TObject;
I:Integer;
CRef:array[0..1] of ClassRef;

{TStudent}
procedure TStudent.ShowInf;
begin
WriteLn('姓名',Name,',学校:',SchoolName);
end;

begin
CRef[0]:=Thuman;
Cref[1]:=TStudent;
for I:=0 to 1 do
begin
Student:=CRef.Create;
if Student is TStudent then
begin
(Student as TStudent).Name:='王松';
(Student as TStudent).SchoolName:='树人小学';
(Student) as TStudent).ShowInf;
end;
end;

Readln;
end.

 
uses
Classes, SysUtils;
 
add classes 后还是错误依旧:
[Error] Project1.dpr(39): Statement expected, but expression of type 'TStudent' found
[Error] Project1.dpr(41): '.' expected but ';' found

光标定位再: (Student) as TStudent).ShowInf;//这一行
 
(Student[blue]) [/blue]as TStudent).ShowInf;
多了一个括号.
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
482
import
I
I
回复
0
查看
536
import
I
I
回复
0
查看
686
import
I
I
回复
0
查看
661
import
I
后退
顶部