field or method identifier expected错误 ( 积分: 80 )

  • 主题发起人 主题发起人 liersbaby
  • 开始时间 开始时间
L

liersbaby

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下,编译的时候报field or method identifier expected,为啥呀?怎么解决
unit TestUtil;

interface

type
ItemGroup = class(TObject)
private
ID : Integer;
GroupName : String;
public

property ItemGroupID : Integer read getID write setID;
property ItemGroupGroupName : String read getGroupName write setGroupName;

procedure setID(ItemGroupID : Integer);
function getID:Integer;
procedure setGroupName(ItemGroupGroupName : String);
function getGroupName:String;
{ Public declarations }
end;


implementation
function ItemGroup.getGroupName: String;
begin
Result := GroupName;
end;

function ItemGroup.getID: Integer;
begin
Result := ID;
end;

procedure ItemGroup.setGroupName(ItemGroupGroupName: String);
begin
if GroupName <> ItemGroupGroupName then
GroupName := ItemGroupGroupName;
end;

procedure ItemGroup.setID(ItemGroupID: Integer);
begin
if ID <> ItemGroupID then
ID := ItemGroupID;
end;

end.
 
代码如下,编译的时候报field or method identifier expected,为啥呀?怎么解决
unit TestUtil;

interface

type
ItemGroup = class(TObject)
private
ID : Integer;
GroupName : String;
public

property ItemGroupID : Integer read getID write setID;
property ItemGroupGroupName : String read getGroupName write setGroupName;

procedure setID(ItemGroupID : Integer);
function getID:Integer;
procedure setGroupName(ItemGroupGroupName : String);
function getGroupName:String;
{ Public declarations }
end;


implementation
function ItemGroup.getGroupName: String;
begin
Result := GroupName;
end;

function ItemGroup.getID: Integer;
begin
Result := ID;
end;

procedure ItemGroup.setGroupName(ItemGroupGroupName: String);
begin
if GroupName <> ItemGroupGroupName then
GroupName := ItemGroupGroupName;
end;

procedure ItemGroup.setID(ItemGroupID: Integer);
begin
if ID <> ItemGroupID then
ID := ItemGroupID;
end;

end.
 
呵呵,是定义顺序问题,先定义get set再定义property就对了,这帖就散分吧
 

Similar threads

I
回复
0
查看
501
import
I
I
回复
0
查看
887
import
I
I
回复
0
查看
965
import
I
I
回复
0
查看
1K
import
I
I
回复
0
查看
676
import
I
后退
顶部