somDefaultConstCopyInit - Remarks

The somDefaultConstCopyInit method would be called a "copy constructor" in C++. In SOM, this concept is supported using an object initializer that accepts the object to be copied as an argument. Copy constructors are used in C++ to pass objects by value. They initialize one object by making it be a copy of another object. In SOM, objects are always passed by reference, so arguments to DTS C++ methods that receive call-by-value object parameters are actually passed by reference. But, to correctly support the semantics of DTS C++ call-by-value arguments, it is necessary to actually pass a copy of the intended argument. A copy constructor can be used to make this copy.

The default behavior provided by somDefaultConstCopyInit is to do a shallow copy of each ancestor class's introduced instance variables. The object being copied is not changed. When a shallow copy is not appropriate, and it is possible to avoid changing fromObj, a class implementor should override somDefaultConstCopyInit (for example, to do a deep copy for certain variables), but should respect the constraint of not modifying the object being copied.

In general, object users should use somDefaultCopyInit to copy an object.

The considerations important to overriding somDefaultConstCopyInit are similar to those described in the SOMobjects Users Guide for overriding somDefaultInit. (See "Initializing and Uninitializing Objects" in Chapter 5, "Implementing Classes in SOM.") The basic difference between somDefaultInit and somDefaultConstCopyInit is that the latter method takes an object (fromObj) as an argument that is to be copied.


[Back: somDefaultConstCopyInit - Parameters]
[Next: somDefaultConstCopyInit - Original Class]