快救我!!!!!我必须在六点钟被救,谢谢各位大哥!!!!

ckbmail 2000-08-25 05:15:00
我有以下代码,是对Tfilestream的一个重栽,但其中的一个方法总不能被编译(用#####表示),希望我能被及时救处火海,谢了!!!鞠躬.请快Emailto:ckbmail@21cn.com
unit mystream;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
Tmystream=class(Tfilestream)
private
fkey:string;
{ Private declarations }
public
#####constructor Create(const FileName: string; Mode: Word);
function read(var buffer;count:longint):longint;override;
function write(const buffer;count:longint):longint;override;
property key:string read fkey write fkey;
{ Public declarations }
end;

type
Tform1=class(Tform)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1:TForm;
implementation

{$R *.DFM}

function tmystream.write(const buffer;count:longint):longint;
var
pbu,pmy,mykey:pchar;
i,enc:integer;
begin
getmem(pmy,count);
mykey:=pchar(key);
try
pbu:=pchar(@buffer);
for i:=0 to count-1 do
begin
enc:=(ord(pbu[i])+ord(mykey[(i mod length(key))])) mod 256;
pmy[i]:=char(enc);
end;
result:=inherited write(pmy^,count);
finally
freemem(pmy,count);
end;
end;

function tmystream.read(var buffer;count:longint):longint;
var
pbu,pmy,mykey:pchar;
i,mycount,enc:integer;
begin
getmem(pmy,count);
mykey:=pchar(key);
try
mycount:=inherited read(pmy^,count);
pbu:=pchar(@buffer);
for i:=0 to mycount-1 do
begin
enc:=(ord(pmy[i])-ord(mykey[(i mod length(key))])) mod 256;
pbu[i]:=chr(enc);
end;
finally
freemem(pmy,count);
end;
result:=mycount;
end;

end.
...全文
181 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
skt642 2001-05-31
  • 打赏
  • 举报
回复
86737关注!
Michaelyfj 2000-08-25
  • 打赏
  • 举报
回复
//你忘记了对Create的实现:

unit MyStream;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
Tmystream=class(Tfilestream)
private
fkey:string;
{ Private declarations }
public
constructor Create(const FileName: string; Mode: Word);
function read(var buffer;count:longint):longint;override;
function write(const buffer;count:longint):longint;override;
property key:string read fkey write fkey;
{ Public declarations }
end;

type
Tform1=class(Tform)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1:TForm;
implementation

{$R *.DFM}

function tmystream.write(const buffer;count:longint):longint;
var
pbu,pmy,mykey:pchar;
i,enc:integer;
begin
getmem(pmy,count);
mykey:=pchar(key);
try
pbu:=pchar(@buffer);
for i:=0 to count-1 do
begin
enc:=(ord(pbu[i])+ord(mykey[(i mod length(key))])) mod 256;
pmy[i]:=char(enc);
end;
result:=inherited write(pmy^,count);
finally
freemem(pmy,count);
end;
end;

function tmystream.read(var buffer;count:longint):longint;
var
pbu,pmy,mykey:pchar;
i,mycount,enc:integer;
begin
getmem(pmy,count);
mykey:=pchar(key);
try
mycount:=inherited read(pmy^,count);
pbu:=pchar(@buffer);
for i:=0 to mycount-1 do
begin
enc:=(ord(pmy[i])-ord(mykey[(i mod length(key))])) mod 256;
pbu[i]:=chr(enc);
end;
finally
freemem(pmy,count);
end;
result:=mycount;
end;

//只要加上这就ok拉
constructor Tmystream.Create(const FileName: string; Mode: Word);
begin
showmessage('糊涂虫,忘了定义');
end;

end.
dandycheung 2000-08-25
  • 打赏
  • 举报
回复
你声明了这个函数,但没有实现它。
dandycheung 2000-08-25
  • 打赏
  • 举报
回复
这是因为你声明了这个函数,但没有实现它。

5,379

社区成员

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

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