solulubeta
Sign in
CS Theory / Object-Oriented Programming
04.04 · Lesson

Constructors & Destructors

A special method invoked automatically at the time of object creation to initialize data members. It has the same name as the class.

3 min Free

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 (~).

Mark this as done when you are finished.

Item 26 of 28 · updated 2026-10-12