传参时类型不匹配,万分感谢!
求助:传参时类型不匹配,万分感谢!!
定义了个递归函数:
-------------------------------------------
interface
uses Windows,Classes,Messages;
type
PKLine=^TKLine;
function EMA(const s:integer;kgroup:TKLineGroup;kline:PKLine;const period:integer):single;
{...}
implementation
function EMA(const s:integer;kgroup:TKLineGroup;kline:PKLine;const period:integer):single;
var
{...}
begin
{...}
if (条件值) then {初始值是0吗?}
result:=... ;
else
result:=EMA(s,kgroup,tmpkline,period);
end;
-----------------------------------------------
引用时的代码:
-----------------------------------------------
var
sz399001m1:TKLineGroup;
pKLine:^TKLine;
implementation
{...}
begin
sz399001m1:= TKLineGroup.Create(self) ;
{...}
New(pKLine);
sz399001m1.KList.Add(pKLine);
pKLine.DIFs:=EMA(1,sz399001m1,pKLine,12); {!!!!!出错行!!!!!}
end;
{...}
-----------------------------------------------
编译时出错:Incompatible types ,怎么会存在类型不匹配呢?怎么解决?万分感谢!!
------解决方案--------------------
pKLine.DIFs是什么类型
------解决方案--------------------
EMA返回single类型, DIFs是什么类型,一致吗
------解决方案--------------------
var
sz399001m1:TKLineGroup;
pKLine:^TKLine;//这行能编译通过吗?类型不匹配的是PKLine跟^TKLine,改成p: PKLine.
然后:
New(p);
sz399001m1.KList.Add(p);
p.DIFs:=EMA(1,sz399001m1,p,12);
定义了个递归函数:
-------------------------------------------
interface
uses Windows,Classes,Messages;
type
PKLine=^TKLine;
function EMA(const s:integer;kgroup:TKLineGroup;kline:PKLine;const period:integer):single;
{...}
implementation
function EMA(const s:integer;kgroup:TKLineGroup;kline:PKLine;const period:integer):single;
var
{...}
begin
{...}
if (条件值) then {初始值是0吗?}
result:=... ;
else
result:=EMA(s,kgroup,tmpkline,period);
end;
-----------------------------------------------
引用时的代码:
-----------------------------------------------
var
sz399001m1:TKLineGroup;
pKLine:^TKLine;
implementation
{...}
begin
sz399001m1:= TKLineGroup.Create(self) ;
{...}
New(pKLine);
sz399001m1.KList.Add(pKLine);
pKLine.DIFs:=EMA(1,sz399001m1,pKLine,12); {!!!!!出错行!!!!!}
end;
{...}
-----------------------------------------------
编译时出错:Incompatible types ,怎么会存在类型不匹配呢?怎么解决?万分感谢!!
------解决方案--------------------
pKLine.DIFs是什么类型
------解决方案--------------------
EMA返回single类型, DIFs是什么类型,一致吗
------解决方案--------------------
var
sz399001m1:TKLineGroup;
pKLine:^TKLine;//这行能编译通过吗?类型不匹配的是PKLine跟^TKLine,改成p: PKLine.
然后:
New(p);
sz399001m1.KList.Add(p);
p.DIFs:=EMA(1,sz399001m1,p,12);