How to work with a copy of an object

Giganews Newsgroups
Subject: How to work with a copy of an object
Posted by:  Stark (franco.jom…@tin.it)
Date: Fri, 04 Mar 2005

I have one class called TAccount and one instance of it, called Account. I
want to make a copy of this object which I can modify without modifying the
first one. What I do now is the following:

var
  copyAccount: TAccount;

.... at a certain point I have an instance of TAccount, called Account, and I
make a copy of it:

copyAccount:= Accont;

then I modify it with something like this:

copyAccount.SetBalance(100);

AND HERE IS MY PROBLEM: I get copyAccount modified, but also Account gets
modified. Why ?

Replies