类中的函数成员如何返回数组?(50分)

  • 主题发起人 主题发起人 nickey
  • 开始时间 开始时间
N

nickey

Unregistered / Unconfirmed
GUEST, unregistred user!
我定义了一个类,在类中要怎么定义一个成员函数, 才能使返回值等于protected里
定义的一个数组,能不能举个例子跟我讲讲?
 
type
Myarray = array[0..i] of string;
TMyObject = class(TObject)
protected
MA: Myarray;
public
fuction MAFunction: Myarray;
end;
function TMyobject.MAFunction:Myarray;
begin
result := MA;
end;
 
Type
TIntArray = array of Array
TCompute = class
protected
FNumArr : TIntArray
//
public
Function GetNumArr : TIntArray
//
end

Function TCompute.GetNumArr : TintArray
begin
Result := FNumArr
end
 
ok... hehe...
 

type tprint=class
private
fhead:integer;ColItem:array of string;);
published
property lineheight:integer read flineheight write setlineheight;
property head:integer read fhead write sethead;
property lx:string read flx write setlx;
property ColCount:integer read fcolcount write setcolcount;
property colName:string read fcolname write setcolname;
property ColItems:string read Fcolitems write setColItems;
^^^^^^^^^^^^
end;
implementation
{ tprint }uses printers;
function tprint.GetColItems(inti: integer): string;
var
intM,intN,intJ:integer;
begin
//get start position
if inti=1 then
intm:=0
else
begin
intm:=pos(',',fcolitems);
fcolitems[intm]:='.';
end;

//get end position
intn:=pos(',',fcolitems);

//return column name
if intn<>0 then
result:=copy(fcolitems,intm+1,intn-intm-1)
else
result:=copy(fcolitems,intm+1,length(fcolitems)-intm);

end;

function tprint.getcolname(i: integer): string;
var
intn,intm:integer;
begin
if i=1 then
intm:=0
else begin
intm:=pos(',',fcolname);
fcolname[intm]:='.';
end;
intn:=pos(',',fcolname);
if intn<>0 then
result:=copy(fcolname,intm+1,intn-intm-1)
else result:=copy(fcolname,intm+1,length(fcolname)-intm);
end;
有点乱了。。
 
后退
顶部