NCERT solutions for class 12 Constructors and Destructors is given here. To solve the questions related to constructors and destructors in CBSE class 12 board exams students must understand what is a constructor and what is a destructor.
Whenever an instance of the class is created the constructor method is called. A constructor is a special member function which enables an object to initialize itself at the time of its creation.
Syntax for declaring constructor
int h, i;
class_name(void); // Constructor Declared
. . .
class_name :: class_name()
h=1; i=2; // Constructor defined
Types of Constructures
- Do nothing constructor
- Default constructor
- Parameterized constructor
- Copy constructor
As the name suggests, a destructor is used to destroy the objects created by the constructors within the program. To name of a destructor is same as that of a constructor but it is preceded by a tilde (~) sign.
Visit the link to download free solutions for NCERT class 12 constructors and destructors PDF.