Results 1 to 3 of 3

Thread: copying class instances

  1. #1

    copying class instances

    If I set one class instance to another they share the same memory and so when the variables in one class change they both change. If I want to copy a class to another class instance so that it's independant do I have to set the variables and properties one at a time or is there a simpler solution?

    Thanks

    Peter

  2. #2

    Re: copying class instances

    Quote Originally Posted by peterbone
    If I want to copy a class to another class instance so that it's independant do I have to set the variables and properties one at a time or is there a simpler solution?
    Basically, yes, although you can make it easy for yourself by giving your classes an Assign() method. Descendants of TPersistent have this already, this would include any VCL components. If these are your own classes then you will have to implement your own methods for doing this.
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  3. #3

    copying class instances

    They're my own classes so I'll write an assign procedure that will copy all the data to the specified instance. Thanks for the help.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •