关于赋值的问题(100分)

  • 主题发起人 主题发起人 flfqnet
  • 开始时间 开始时间
F

flfqnet

Unregistered / Unconfirmed
GUEST, unregistred user!
unit ZT_SongSixOKData;

interface
Uses
Windows, Classes,SysUtils, Controls;

Type
//歌曲信息数据结构
PSongInfo=^TSongInfo ;
TSongInfo=Record
Code:Array[0..7] of char;
Name:Array[0..39] of char;
Language:char;
Num:Array[0..1] of char;
Singer1:Array[0..3] of char;
unknow1:char;
Area1:char;
Singer2:Array[0..3] of char;
unknow2:char;
Area2:char;
Type1:char;
Type2:char;
PinYin:Array[0..7] of char;
ZhuYin:Array[0..7] of char;
Index:char;
unknow3:Array[0..7] of char;
Duet:char;
Version:char;
Media :char;
CharSet:char;
SwapTrack:char;
End;


TZTDataSix = class(TObject)
private

FTSongInfo:TSongInfo;

public

constructor Create;
destructor Destory;


published

property FilterSongInfo :TSongInfo
read FTSongInfo Write FTSongInfo;

end;

implementation


constructor TZTDataSix.Create;
Var
MyFilterSongInfo:TSongInfo;
Begin
//如初化筛选值
MyFilterSongInfo.Code :='';
MyFilterSongInfo.Name :='';
MyFilterSongInfo.Language :=#0;
MyFilterSongInfo.Num :='';
MyFilterSongInfo.Singer1 :='';
MyFilterSongInfo.unknow1 :=#0;
MyFilterSongInfo.Area1 :=#0;
MyFilterSongInfo.Singer2 :='';
MyFilterSongInfo.unknow2 :=#0;
MyFilterSongInfo.Area2 :=#0;
MyFilterSongInfo.Type1 :=#0;
MyFilterSongInfo.Type2 :=#0;
MyFilterSongInfo.PinYin :='';
MyFilterSongInfo.ZhuYin :='';
MyFilterSongInfo.Index :=#0;
MyFilterSongInfo.unknow3 :='';
MyFilterSongInfo.Duet :=#0;
MyFilterSongInfo.Version :=#0;
MyFilterSongInfo.Media :=#0;
MyFilterSongInfo.CharSet :=#0;
MyFilterSongInfo.SwapTrack :=#0;
{
问题出在这里,只能对
FilterSongInfo:=MyFilterSongInfo;这样赋值
如果使用
FilterSongInfo.Code='';
编译就会提示,不能对左边进行赋值
我想问一下
能不能让我的类中属性如
A.FilterSongInfo.Code 进行赋值
}
FilterSongInfo:=MyFilterSongInfo;
End;

destructor TZTDataSix.Destory;
Begin
End;


end.
 
你把你类中的需要赋值的地方写在public区吧,但是这样的话就完全违反了类的原则,在类里面,如果需要对类的成员访问的话,为了保护类的完整性,需要通过相关的访问函数来进行的,你可以看看delphi中各种类的实现就知道了.
 
正在看,但看的头大
 
放到 public 还是提示 不能对左边进行赋值
 
StrCopy(FilterSongInfo.Code,'');
你的code是个char数组,所以不能那样赋值
还有,你的代码真是有够烂,连Destroy也写错,还没用override关键字
 
哈哈,刚发现,上面的代码是临时拿了个记事本写的,主要是脑袋转的比手快,脑子里应想的是对的,打错了

:0
 
我想问题不是用
StrCopy(FilterSongInfo.Code,'');
来解决的
因为
MyFilterSongInfo.Code :='';
这样符值是正常的
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
560
import
I
I
回复
0
查看
566
import
I
I
回复
0
查看
787
import
I
后退
顶部