encyclopegia.org

Object copying

In object-oriented programming, object copying is creating a copy of an existing object, a unit of data in object-oriented programming.[src] The resulting object is called an object copy or simply copy of the original object.[src] Copying is basic but has subtleties and can have significant overhead.[src] There are several ways to copy an object, most commonly by a copy constructor or cloning.[src] Copying is done mostly so the copy can be modified or moved, or the current value preserved.[src] If either of these is unneeded, a reference to the original data is sufficient and more efficient, as no copying occurs.[src] Objects in general store composite data.[src] While in simple cases copying can be done by allocating a new, uninitialized object and copying all fields (attributes) from the original object, in more complex cases this does not result in desired behavior.[src]

In object-oriented programming, object copying is creating a copy of an existing object, a unit of data in object-oriented programming.[src] The resulting object is called an object copy or simply copy of the original object.[src] Copying is basic but has subtleties and can have significant overhead.[src] There are several ways to copy an object, most commonly by a copy constructor or cloning.[src] Copying is done mostly so the copy can be modified or moved, or the current value preserved.[src] If either of these is unneeded, a reference to the original data is sufficient and more efficient, as no copying occurs.[src] Objects in general store composite data.[src] While in simple cases copying can be done by allocating a new, uninitialized object and copying all fields (attributes) from the original object, in more complex cases this does not result in desired behavior.[src] The Eiffel class ANY contains features for shallow and deep copying and cloning of objects.[src] All Eiffel classes inherit from ANY , so these features are available within all classes, and are applicable both to reference and expanded objects.[src] The copy feature effects a shallow, field-by-field copy from one object to another.[src] In this case no new object is created.[src] If y were copied to x , then the same objects referenced by y before the application of copy , will also be referenced by x after the copy feature completes.[src] To effect the creation of a new object which is a shallow duplicate of y , the feature twin is used.[src] In this case, one new object is created with its fields identical to those of the source.[src] The feature twin relies on the feature copy , which can be redefined in descendants of ANY , if needed.[src] The result of twin is of the anchored type like Current .[src] Deep copying and creating deep twins can be done using the features deep_copy and deep_twin , again inherited from class ANY .[src] These features have the potential to create many new objects, because they duplicate all the objects in an entire object structure.[src] Because new duplicate objects are created instead of simply copying references to existing objects, deep operations will become a source of performance issues more readily than shallow operations.[src] In Perl, nested structures are stored by the use of references, thus a developer can either loop over the entire structure and re-reference the data or use the dclone() function from the module Storable.[src] In VBA, an assignment of variables of type Object is a shallow copy, an assignment for all other types (numeric types, String, user defined types, arrays) is a deep copy.[src] So the keyword Set for an assignment signals a shallow copy and the (optional) keyword Let signals a deep copy.[src] There is no built-in method for deep copies of Objects in VBA.[src] ==Notes==[src]

33 sentences · 33 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Object copying." encyclopegia.org, 2026, https://encyclopegia.org/wiki/object-copying. Accessed 26 November 2026.

Chicago

"Object copying." encyclopegia.org. Accessed November 26, 2026. https://encyclopegia.org/wiki/object-copying.

APA

encyclopegia.org. (2026). Object copying. Retrieved November 26, 2026, from https://encyclopegia.org/wiki/object-copying

Accessed November 26, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Digital Object Identifier

article · references available

Electronic Object Identifier

article · references available

trans-Neptunian object

stub · references available

Messier object

stub · references available

object

stub · references available

plain old Java object

stub · references available

Object Data Management Group

stub · references available

hidden file system object

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1364772801 · 0.5 · snapshot enwiki-001364772801

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.