Advanced Study Material for Class 12 Computer Science: Constructors and Destructors
Access comprehensive study materials and useful resources for Constructors and Destructors using the Class 12 Constructors and Destructors Revision Notes. Designed to align with the 2026-27 CBSE academic guidelines, these advanced resources help Class 12 Computer Science students reinforce core concepts beyond standard textbooks.
Practice Class 12 Computer Science Resources: Constructors and Destructors
View or download the dedicated Class 12 Constructors and Destructors Revision Notes resource below. Engaging with these advanced study guides under focused conditions ensures continuous academic progress and mastery of the 2026-27 curriculum for Constructors and Destructors.
Unit I – Object Oriented Programming in C++
Chapter 3: Constructors and Destructors (Revision Notes)
Constructor: A constructor is a special member function with the same name as its class. It is used to initialise the data members of the class. A constructor is invoked automatically when an object of the class is created. A constructor does not return any value, not even void. A constructor must be defined in the public section.
Types of constructors
- Default constructor (no-argument constructor): A default constructor accepts no parameters. When no constructor is defined in the class, the compiler provides a default constructor.
- Parameterised constructor (overloaded constructor): A parameterised constructor accepts parameters and uses them to assign values to the data members of the class. There may be many definitions of the parameterised constructor, depending on the type and number of the parameters passed to it, so it is also called an overloaded constructor.
- Copy constructor: A constructor that accepts a reference to an object of its own class as an argument is called a copy constructor. It is used to create a new object with the same values as an existing object. A copy constructor is invoked when an object is defined and initialised with another object of the same class.
Syntax for the declaration of a copy constructor:
classname(classname &obj)For example: Student(Student &s)
Example of the three types of constructors (default, parameterised, copy):
#include<iostream.h>
class student
{
int rollno;
float percentage;
public:
student() // default constructor
{
rollno=0;
percentage=0.0;
}
student(int rno,float p) // parameterised constructor
{
rollno=rno;
percentage=p;
}
student(student &s) // copy constructor
{
rollno=s.rollno;
percentage=s.percentage;
}
void display()
{
cout<<"RNo. "<<rollno;
cout<<"\n per "<<percentage;
}
};
void main()
{
student s; // call for the default constructor
student s1(5,88.5); // call for the parameterised constructor
student s2=s1; // call for the copy constructor
s.display();
s1.display();
s2.display();
}Note 1: When a parameterised constructor is defined, the default constructor must also be defined. Otherwise an error may occur when a call to the default constructor is made.
Note 2: When multiple constructors are defined for a class, it is known as constructor overloading.
Short answer type questions (2 marks)
What do you understand by constructor and destructor?
Answer: A constructor is a special member function with the same name as the class. It is called automatically when an object is created, and it initialises the data members. A destructor is also a special member function with the same name as the class, but with a tilde (~) in front of it. It is called automatically when an object is destroyed (for example, when it goes out of scope), and it releases the resources the object was using. A destructor has no arguments and no return type, and a class can have only one destructor. Neither of them returns a value.
What are the different types of constructors?
Answer: The three types are the default constructor (no arguments), the parameterised constructor (takes arguments), and the copy constructor (takes a reference to an object of the same class).
What do you understand by a default constructor? What is its role?
Answer: A default constructor is a constructor that accepts no parameters. Its role is to initialise the data members of an object to default values when the object is created without any arguments, for example student s;. If a class has no constructor, the compiler supplies a default constructor automatically.
Answer the questions (i) and (ii) after going through the following class.
class Race
{
int CarNo,Track;
public:
Race(); //function 1
Race(int CN); //function 2
Race(Race &R); //function 3
void Register(); //function 4
void Drive(); //function 5
};
void main()
{
Race R;
}(i) Out of the following, which of the options is correct for calling function 2?
Option 1 – Race T(30);
Option 2 – Race U(R);
(ii) Name the feature of object oriented programming which is illustrated by function 1, function 2 and function 3 combined together.
Answer: (i) Option 1, Race T(30);, is correct, because it passes one integer argument. Option 2, Race U(R);, calls function 3 (the copy constructor).
(ii) Constructor overloading, which is an example of polymorphism.
What is a copy constructor? What do you understand by constructor overloading?
Answer: A copy constructor is a constructor that takes a reference to an object of its own class and creates a new object with the same values as the existing object. Constructor overloading means defining more than one constructor in the same class, with different numbers or types of parameters. The compiler chooses the constructor that matches the arguments given when the object is created.
Find the output of the following.
#include<iostream.h>
class METRO
{
int Mno, TripNo, PassengerCount;
public:
METRO(int Tmno=1)
{
Mno= Tmno;
TripNo =0;
PassengerCount=0;
}
void Trip(int PC=20)
{
TripNo++;
PassengerCount +=PC;
}
void StatusShow()
{
cout<<Mno<<":"<<TripNo<<":"<<PassengerCount<<endl;
}
};
void main()
{
METRO M(5),T;
M.Trip();
T.Trip(50);
M.StatusShow();
M.Trip(30);
T.StatusShow();
M.StatusShow();
}Answer: The output is:
5:1:20
1:1:50
5:2:50Explanation: M(5) sets Mno to 5, and T uses the default value 1. M.Trip() uses the default PC of 20, so M has TripNo 1 and PassengerCount 20. T.Trip(50) gives T TripNo 1 and PassengerCount 50. So the first M.StatusShow() prints 5:1:20. M.Trip(30) makes M have TripNo 2 and PassengerCount 50. Then T.StatusShow() prints 1:1:50, and the last M.StatusShow() prints 5:2:50.
Free study material for Computer Science
CBSE Class 12 Computer Science Study Material: Constructors and Destructors
Essential Notes for Class 12 Computer Science
Access comprehensive study material for Constructors and Destructors, including revision notes, concept maps, and high-probability questions. These resources are designed in alignment with the latest 2026 CBSE syllabus for Class 12 Computer Science to support effective exam preparation.
Verified Solutions for Class 12 Computer Science
Each resource draws directly from authorized textbooks to maintain academic accuracy. Evaluating solved examples allows Class 12 students to master the formal presentation and answer-writing standards expected in upcoming school exams.
Enhance Accuracy with Online Tests
Wrap up your chapter revision by testing your knowledge against standard objective question formats. Explore our full library of free, up-to-date sample papers and online assessments to secure top grades in your CBSE examinations.
FAQs
Our advanced study package for Constructors and Destructors includes detailed concepts, diagrams, Mind Maps, and explanation of complex topics to ensure Class 12 students learn as per syllabus for 2026 exams.
The Mind Maps provided for Constructors and Destructors act as visual anchors which will help faster recall during high-pressure exams.
Yes, teachers use our Class 12 Computer Science resources for lesson planning as they are in simple language and have lot of solved examples.
Yes, You can download the complete, mobile-friendly PDF of the Computer Science Constructors and Destructors advanced resources for free.
Yes, our subject matter experts have updated the Constructors and Destructors material to align with the rationalized NCERT textbooks and have removed deleted topics and added new competency-based questions.