【发布时间】:2012-01-30 18:20:11
【问题描述】:
看看下面的代码:
method TMakerRect.Clone: TMakerObject;
var
newRect:TMakerRect;
begin
newRect := new TMakerRect(bounds,myForm);
newRect.Assign(Self);
newRect.theBrushStyle := Self.theBrushStyle;
Result := newRect;
end;
method TMakerGraphic.Assign(obj:TMakerObject);
begin
inherited Assign(obj);
if obj is TMakerGraphic then
begin
thePen:=TmakerGraphic(obj).thePen;
FillColor:=TMakerGraphic(obj).fillColor;
dynamics:=TmakerGraphic(obj).dynamics;
end;
end;
我认为这就是您对对象进行深拷贝克隆的方式。如果这是真的,这些对象应该表现得好像它们是单独的对象,但事实并非如此。例如,每当我改变笔的宽度时,它也会改变原始对象的笔宽度。请帮忙。
提前致谢。
【问题讨论】:
标签: .net object clone delphi-prism