Order of calling constructors and Destructors

Nasza ocena:

3
Wyświetleń: 441
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
Order of calling constructors and Destructors - strona 1 Order of calling constructors and Destructors - strona 2 Order of calling constructors and Destructors - strona 3

Fragment notatki:

Order of calling constructors and Destructors  Constructors 1. base class (classes in order of declaration) 2. class members in order of declaration 3. constructor's body  Destructors - simply opposite order 1. destructor's body 2. destructors of class members (order opposite to declaration) 3. destructor of the base class (classes in order opposite to declaration)  objects defined in blocks (local, automatic) - constructors are called when the definition is executed - destructors after leaving the block, order opposite to constructors  global objects (static) - constructors are called in an order of objects' definitions, before calling the main() function - destructors in order opposite to constructors, after leaving main().  dynamic objects are controlled by the programmer (new and delete)  memory allocation and a constructor call: when the operator new is executed  destructor and deallocation: delete ... zobacz całą notatkę



Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz