一个比较棘手的问题,请大家教教我好吗

really168 2004-01-31 09:37:52
unit Unit1;

interface

uses
SysUtils, Types, Classes, Variants, QTypes, QGraphics, QControls, QForms,
QDialogs, QStdCtrls;

type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
ListBox1: TListBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label7: TLabel;
queue=array[1..4,1..20] of real; 在编译的时候就是这里错了,是怎么
function aver(queue1:queue;m,n:integer);real; 回事啊
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
i:integer;
score:queue;

function aver(queue1:queue;m,n:integer):real;
var
k:integer;
sum:real;
begin
sum:=0;
for k:=1 to n do
sum:=sum+queue1[m][k];
aver:=sum/n;
end;

implementation

{$R *.xfm}

end.


这个程序没写完,当我写完这点的时候想写一些按钮代码的时候,每当我点按钮的时候都会出错,显示说 Expected ':'but '=' found请问这是怎么回事啊
请帮帮我啊
...全文
23 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
sookeer 2004-02-01
  • 打赏
  • 举报
回复
我怎么看也觉得是定义的部分的代码的地方不正确吧。
你写的函数的实现区应该是在implementation {$R *.xfm} 之后吧,就是一个公共变量也是在这个地方来实现的。i,score定义的地方也也不正确。应该仔细看以下各个部分的含义。


yyfhz 2004-02-01
  • 打赏
  • 举报
回复
补充 delphi_xizhousheng(西周生)
1.方法 function aver(queue1:queue;m,n:integer); real;本身的定义语句有问题
应该是 function aver(queue1:queue;m,n:integer): real;
2.方法中使用了queue这样的数据类型,因此,在这之前必须有queue的类型定义。
这样的话,你最好使用这样的格式
type
queue=array[1..4,1..20] of real; //定义类型queue
TForm1= class(TForm)
...
function aver(queue1:queue;m,n:integer): real;
...
end;
delphi_xizhousheng 2004-02-01
  • 打赏
  • 举报
回复
var
queue:array[1..4,1..20] of real;

type queue=array[1..4,1..20] of real;
really168 2004-02-01
  • 打赏
  • 举报
回复
还是不行的,我早就拭了
youcheng1 2004-01-31
  • 打赏
  • 举报
回复
queue:array[1..4,1..20] of real;
哈哈~~,没注意。
ahjoe 2004-01-31
  • 打赏
  • 举报
回复
编译器已经告诉你需要":"
ahjoe 2004-01-31
  • 打赏
  • 举报
回复
蠢啊
queue:array[1..4,1..20] of real;
really168 2004-01-31
  • 打赏
  • 举报
回复
还是行啊,书上说是 在interface部分声明类型标示queue,函数aver,以及两个全局变量i和score
我这样写对吗
youcheng1 2004-01-31
  • 打赏
  • 举报
回复
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
ListBox1: TListBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label7: TLabel;

function aver(queue1:queue;m,n:integer);real; 回事啊
private
queue=array[1..4,1..20] of real; 这是窗体私有变量。
public
{ Public declarations }
end;
youcheng1 2004-01-31
  • 打赏
  • 举报
回复
如果声明的是窗体的私有就量,需要放在private段中,不需要VAR。
你试试
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
ListBox1: TListBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label7: TLabel;

function aver(queue1:queue;m,n:integer);real; 回事啊
var
queue=array[1..4,1..20] of real; 这是公共变量
really168 2004-01-31
  • 打赏
  • 举报
回复
难道就少了VAR吗
youcheng1 2004-01-31
  • 打赏
  • 举报
回复
声明就是时要有VAR

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧