Prof. A Olowofoyeku (The African Chief) wrote:
On 21 Mar 2001, at 16:15, Maurice Lombardi wrote:
Yes, it does - but I am not sure which destructor you would be calling after such an assignment. Remember that instances of classes are pointers to the objects - so in the assignment, what you are moving around are pointers, and there may be gotchas there.
But as far as I remember delphi knows the actual type of an object at run time from the address of the VMT (there is one VMT for each defined object type) which he recovers at a fixed displacement from the address given by the object pointer.
Well, the example code causes an exception at the point where you call "h1.free" (if you do the assignment "h1 := h2"). This happens both under Delphi and Virtual Pascal (which is Delphi-compatible). So there is obviously an issue there.
yes but that's because in this code you do two free's. After the assignment h1 and h2 point to the same location. You then can do only one free (h1.free or h2.free), in any order. The exception arises only on the second free because the second pointer points then to nowhere.
Cheers, Maurice