Tous les livres

Professionnel

Applis À propos Coach Connexion Commencer la lecture

Computer Science · Glossaire

Qu'est-ce que « Copy constructor, copy assignment operator » ?

Aussi appelé : copy constructor · copy assignment operator

Definition 2.1 University Computer Science — Year 2 · Chapitre 2 — Copying, Moving and Smart Pointers

The copy constructor of a class T is the constructor T(const T &): it builds a new object from an existing one, as in T b = a; or when a is passed by value. The copy assignment operator T &operator=(const T &) gives an existing object the value of another, as in b = a;. If a class declares neither, the compiler writes them: they copy each member in turn.

Lire dans le chapitre →