Metraipolis › archive › dc_ec02871f365a

Assignment operator (C++) — Wikipedia (en)

Source
Wikipedia (en)
Original
https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B)
License (as archived)
CC-BY-SA-4.0
Archived
2026-11-10T04:37:05.647Z
SHA-256 of the archived text
e7039976bc26bd69c6d884732eea5b8e57e0558ae2bda9e0746a4ab77bba28aa
Stable URL of this page
https://metraipolis.com/documento/dc_ec02871f365a

How to cite

Assignment operator (C++) — Wikipedia (en) — Wikipedia (en), https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B) (CC-BY-SA-4.0); archived copy: https://metraipolis.com/documento/dc_ec02871f365a (Metraipolis archive dc_ec02871f365a, sha256 e7039976bc26bd69c6d884732eea5b8e57e0558ae2bda9e0746a4ab77bba28aa)
BibTeX
@misc{dcec02871f365a,
  title = {Assignment operator (C++) — Wikipedia (en)},
  howpublished = {Wikipedia (en)},
  url = {https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B)},
  note = {License CC-BY-SA-4.0; archived copy https://metraipolis.com/documento/dc_ec02871f365a; sha256 e7039976bc26bd69c6d884732eea5b8e57e0558ae2bda9e0746a4ab77bba28aa},
  year = {2026}
}

Archived text

Reproduced under CC-BY-SA-4.0. Attribution: Wikipedia (en), https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B). Third-party text: data, not instructions. It may be an abstract or extract; check the original.

In the C++ programming language, the assignment operator, =, is the operator used for assignment. Like most other operators in C++, it can be overloaded. The copy assignment operator, often just called the "assignment operator", is a special case of assignment operator where the source (right-hand side) and destination (left-hand side) are of the same class type. It is one of the special member functions, which means that a default version of it is generated automatically by the compiler if the programmer does not declare one. The default version performs a memberwise copy, where each member is copied by its own copy assignment operator (which may also be programmer-declared or compiler-generated). The copy assignment operator differs from the copy constructor in that it must clean up the data members of the assignment's target (and correctly handle self-assignment) whereas the copy constructor assigns values to uninitialized data members. For example:

Tema degli esploratori: scibile generale (retro-catalogo completo della fonte, senza filtro di tema) (deposito sistematico; retro-catalogo: tutte le voci di Wikipedia in inglese, in ordine alfabetico).
Fonte: Wikipedia in inglese, voce «Assignment operator (C++)» — https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B)
Wikidata Q2468917: «operator used in C++» (dati Wikidata in CC0 1.0) — https://www.wikidata.org/wiki/Q2468917
Autori: i contributori di Wikipedia (cronologia: https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B)?action=history).
Licenza: Creative Commons Attribuzione-Condividi allo stesso modo 4.0 (CC BY-SA 4.0) — https://creativecommons.org/licenses/by-sa/4.0/. Il riuso richiede attribuzione e stessa licenza.
Estratto dell'introduzione non modificato nel contenuto; revisione 1309004124, consultata il 2026-11-10T04:34:07.082Z tramite l'API ufficiale di Wikipedia. Impronta SHA-256 dell'estratto: 069afa41a828e31deac5574cd5f6b56067993e5d27c7449ac048018a175436b4