delphi 编译出现的问题

gongzhaohan 2011-03-24 05:10:32
program Project2;

{$APPTYPE CONSOLE}

uses
SysUtils,
Unit1 in 'Unit1.pas',
Unit2 in 'Unit2.pas',
Unit3 in 'Unit3.pas',
Unit4 in 'Unit4.pas',
Unit5 in 'Unit5.pas',
Unit6 in 'Unit6.pas';

var t_send : TSend;
var t_rcv : TRecv;
var t_msg :=CMessage.Create(136,111,'hello world');
begin
{ TODO -oUser -cConsole Main : Insert code here }
t_send.msgConnectedTo(t_rcv);
t_send.sendMessage(t_msg);
end.




编译后var t_msg :=CMessage.Create(136,111,'hello world');
这行有问题:error为[Error] Project2.dpr(16): ',' or ':' expected but ':=' found
[Error] Project2.dpr(16): ',' or ':' expected but '(' found
这是什么问题啊?
其中CMessage是一个类 就是初始化一个对象。

谢谢






...全文
47 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lw19860412 2011-03-24
  • 打赏
  • 举报
回复
这个问题
sforiz 2011-03-24
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 bdmh 的回复:]

var t_msg :=CMessage.Create(136,111,'hello world');
这种定义不允许,创建要放到代码中
[/Quote]

正解
bdmh 2011-03-24
  • 打赏
  • 举报
回复
var t_msg :=CMessage.Create(136,111,'hello world');
这种定义不允许,创建要放到代码中
chenzhuo 2011-03-24
  • 打赏
  • 举报
回复

uses
SysUtils,
Unit1 in 'Unit1.pas',
Unit2 in 'Unit2.pas',
Unit3 in 'Unit3.pas',
Unit4 in 'Unit4.pas',
Unit5 in 'Unit5.pas',
Unit6 in 'Unit6.pas';

var t_send : TSend;
t_rcv : TRecv;
t_msg : CMessage;

begin
Ct_msg := CMessage.Create(136,111,'hello world');

{ TODO -oUser -cConsole Main : Insert code here }
t_send.msgConnectedTo(t_rcv);
t_send.sendMessage(t_msg);
end.

16,749

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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