The Need for Copy Constructors
21 posts
• Page 3 of 3 • 1, 2, 3
Re: The Need for Copy Constructors
As far as I need it in my applications, it does work for derived classes.
The ∆CopyFrom and ∆CopyTo properties are implemented in one central base class that I derive from. This base class also implements a MakeMeACloneOf method.
The basic functionality lies in the line ∆CopyTo←SourceObject.∆CopyFrom.
Depending on the degree of privacy you implement in your classes you may find it necessary to have this line in some method in your derived class as well.
If the fields in your object instances contain data values like classic APL variables, everything works fine.
If some of the fields in your class contain (references to) instances of objects or references to namespaces MakeMeACloneOf creates references to the originals. in that case, think twice before use, it may harm your application.
So, to get what my application really needs, some of my derived classes implement their own
MakeMeACloneOf method which after the basic ∆CopyTo←SourceObject.∆CopyFrom do some more sophisticated stuff.
The ∆CopyFrom and ∆CopyTo properties are implemented in one central base class that I derive from. This base class also implements a MakeMeACloneOf method.
The basic functionality lies in the line ∆CopyTo←SourceObject.∆CopyFrom.
Depending on the degree of privacy you implement in your classes you may find it necessary to have this line in some method in your derived class as well.
If the fields in your object instances contain data values like classic APL variables, everything works fine.
If some of the fields in your class contain (references to) instances of objects or references to namespaces MakeMeACloneOf creates references to the originals. in that case, think twice before use, it may harm your application.
So, to get what my application really needs, some of my derived classes implement their own
MakeMeACloneOf method which after the basic ∆CopyTo←SourceObject.∆CopyFrom do some more sophisticated stuff.
- uwejanza
- Posts: 19
- Joined: Tue Mar 09, 2010 2:01 pm
- Location: Nürnberg, Germany
21 posts
• Page 3 of 3 • 1, 2, 3
Return to Object Oriented Programming
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group