constructor and Destructors in C++ hindi

Sdílet
Vložit
  • čas přidán 22. 05. 2020
  • #Constructor:
    - Constructor is an special member function of a class used to allocate the memory of objects.
    Features:
    Constructor has same name as class.
    Constructor has no return type (even not void).
    Constructor can initialize the member data of class.
    Constructor called automatically when object is created.
    #Destructors:
    - Destructor is another special member function used to release the memory occupied by the objects at the end of scope.
    Features:
    Destructor has same name as class with tiled (~) symbol.
    Destructor has no return type (even not void).
    Destructor called automatically when scope of object goes end.
    Destructors called automatically in reverse order of constructors.
    One class may have only one Destructor.

Komentáře • 56