04.04 · Lesson
Constructors & Destructors
Constructor
A special method invoked automatically at the time of object creation to initialize data members. It has the same name as the class.
- Default constructor: Has no argument.
- Parameterized constructor: Has parameters to provide different values to distinct objects.
- Copy Constructor: Overloaded constructor used to declare and initialize an object from another object (default and user-defined).
Destructor
Works opposite to constructor; it destructs objects of classes. Defined only once in a class, invoked automatically, and prefixed with a tilde sign (~).
Item 26 of 28 · updated 2026-10-12