function StrComp(S1,S2:string):string; begin if AnsiContainsStr(S1,S2) then result:=S1 else result:=S1+S2 end;
delphi用属性的作用? 类、封装
function StrComp(S1,S2:string):string; begin if strpos(pchar(S1),pchar(S2))<>nil then result:=S1; else result:=S1+S2; end; 属性的作用,比如可以判别输入的合法性,它是代码的一种访问机制。也是一种良好的封装。
begin
if AnsiContainsStr(S1,S2) then
result:=S1
else
result:=S1+S2
end;
类、封装
begin
if strpos(pchar(S1),pchar(S2))<>nil then
result:=S1;
else
result:=S1+S2;
end;
属性的作用,比如可以判别输入的合法性,它是代码的一种访问机制。也是一种良好的封装。