SlideShare a Scribd company logo
Presented by:-Shubham Vishwambhar
1. CONSTRUCTOR
2. DEFAULT CONSTRUCTOR
3. PARAMETERIZED CONSTRUCTOR
4. COPY CONSTRUCTOR
5. OVERLOADING CONSTRUCTOR
6. DESTRUCTOR
1. Special member function to initialize
2. The objects of its class.
3. Its name is same as the class name.
4. It is invoked whenever the object is
created.
Class integer
{
Int m,n;
Public :
Integer();//constructor
Declared
……
};
Constructor defination
Integer :: integer()
{
M=0;
N=0;
}
1. They should be declared in the public section.
2. They are called automatically when the object are
created.
3. They do not have return type even void
4. They have same name as the class name.
1. They takes no parameters.
2. They are called internally by the compiler
whenever the object are created.
3. There is no need to call it explicitly
#include<iostream.h>
#include<conio.h>
Class stud
{
Int m,n;
Public:
Stud()
{
M=0;
n-=0;
}
Void display()
{
Cout<<“m&n=”<<m<<n;
}
};
Void main()
{
Clrscr();
Stud s;
s.display();
Getch();
}
1. These are the constructor that take arguments.
2. They initialized the object data members by the value
which is passed as arguments.
3. They are invoked when we pass the arguments to the
object when they are being defined.
4. Example: integer int1(2,5);
#include<iostream.h>
#include<conio.h>
Class stud
{
Int m,n;
Public:
Stud(int x, int y)
{
m=x;
n=y;
}
Void display();
{
Cout<<“m&n=“<<m<<n;
}
};
Void main()
{
Clrscr();
Stud S(5,6);
S.display();
Getch();
}
1. It is used to declare and initialized
an object from another object.
2. It takes reference to an object of
the same class as itself as an
arguments.
#include<iostream . h>
#include<conio . h>
Class stud
{
Int m , n;
Public:
Stud(stud & x)
{
m=x.m;
n=x.n;
}
Stud()
{
m=100;
n=100;
}
Void display()
{
Cout<<m&n=“<<m<<n;
}
};
void main()
{
clrscr(); integer
int1;
int1.display();
integer
int2(int1);
int2.display();
getch();
}
1. Constructor overloading is the process of
defining more than one constructor in the
same class.
2. C++ permits us to use multiple constructor in
the same class.
#include<iostream.h>
#include<conio.h>
Class stud
{
Int m,n;
Public:
Stud(stud&x)
{
m=x.m;
n=x.n;
}
Stud()
{
m=0;
n=0;
}
Stud(int x , int y);
{
m=x;
n=y;
}
Void display()
{
Cout<<“m&n=“<<m
<<n;
}
};
Void main()
{
Clrscr();
Stud S1;
Stud S2(400,500);
Stud S3(S2);
S1.display();
S2.display();
S3.display();
Getch();
}
1. It is used to destroy the objects created by
the constructor.
2. It is called for the class object whenever it passes
the scope in the program.
3. Whenever new is used in the constructor to
allocate the memory delete should be used in the
destructor to free the memory for future use.
1. It has same name as the class name but is
preceded by tilde (~) sign.
2. It has no return type and do not take any
arguments.
3. It can not be overloaded.
4. It is called whenever the object get out of its
scope.
#include<iostream.h>
#include<conio.h>
{
Int m,n;
Public:
Stud()
{
m=0;
n=0;
Cout<<“deafault
constructor is
called”<<endl;
Stud(int x, int y)
{
m=x;
n=y;
Cout<<“parameterized
constructor is
called”<<endl;
}
~stud()
{
Cout<<“object is
destroyed:<<endl;
Void display()
{
Cout<<“m&n=“<<m<<
n<<endl’
}
};
Void main()
{
Clrscr();
{
Stud S1;
S1.display();
}
{
Stud S2;
S2.display();
}
Getch();
}
ANY QUESTIONS?
 Wikipedia.com/constructor
 Wikipedia.com/destructor
 slideshare.com

More Related Content

PPTX
classes and objects in C++
PPTX
Control Statements in Java
PPTX
PPT
RECURSION IN C
PPT
Method overriding
PPTX
Data types in c++
PDF
Constructor and Destructor
PDF
Constructors and Destructors
classes and objects in C++
Control Statements in Java
RECURSION IN C
Method overriding
Data types in c++
Constructor and Destructor
Constructors and Destructors

What's hot (20)

PPTX
07. Virtual Functions
PPTX
C++ presentation
PPT
C by balaguruswami - e.balagurusamy
PPTX
Conditional statement c++
PPT
friend function(c++)
PPTX
Control statements in c
PDF
Classes and objects
PDF
Java conditional statements
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
PPTX
Multiple inheritance possible in Java
PPT
Class and object in C++
PDF
Constructors and destructors
PPTX
Virtual base class
PPTX
Interfaces in java
PPTX
Interface in java
PPTX
Basic Data Types in C++
PPTX
Functions in c++
PPT
Files in c++ ppt
PDF
Function overloading ppt
PPTX
Function overloading
07. Virtual Functions
C++ presentation
C by balaguruswami - e.balagurusamy
Conditional statement c++
friend function(c++)
Control statements in c
Classes and objects
Java conditional statements
Basic Concepts of OOPs (Object Oriented Programming in Java)
Multiple inheritance possible in Java
Class and object in C++
Constructors and destructors
Virtual base class
Interfaces in java
Interface in java
Basic Data Types in C++
Functions in c++
Files in c++ ppt
Function overloading ppt
Function overloading
Ad

Viewers also liked (20)

PPTX
constructor & destructor in cpp
PPTX
Constructors & destructors
PPTX
Constructor and destructor in c++
PDF
01. introduction to C++
PPTX
Inheritance in OOPS
PDF
04. constructor & destructor
PPT
Inheritance OOP Concept in C++.
PDF
03. oop concepts
PDF
4GMAT Diagnostic Test Q14 - Problem Solving - Coordinate Geometry
PPT
Constructor and Destructor PPT
PPTX
File system implementation
PPTX
File System Implementation
PPTX
03 Java Language And OOP Part III
PPTX
Constructor & destructor
PDF
Access modifiers in java
PPTX
Inheritance in oops
PPT
Chapter 11 - File System Implementation
PDF
File System Implementation - Part1
PPT
Constructor & Destructor
PPTX
Constructor ppt
constructor & destructor in cpp
Constructors & destructors
Constructor and destructor in c++
01. introduction to C++
Inheritance in OOPS
04. constructor & destructor
Inheritance OOP Concept in C++.
03. oop concepts
4GMAT Diagnostic Test Q14 - Problem Solving - Coordinate Geometry
Constructor and Destructor PPT
File system implementation
File System Implementation
03 Java Language And OOP Part III
Constructor & destructor
Access modifiers in java
Inheritance in oops
Chapter 11 - File System Implementation
File System Implementation - Part1
Constructor & Destructor
Constructor ppt
Ad

Similar to Constructor and destructor (20)

PPTX
Constructor
PPTX
Constructor and desturctor
PPTX
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
PPTX
OOP-Lecture-05 (Constructor_Destructor).pptx
PPTX
constructors and destructors
PDF
Constructors & Destructors [Compatibility Mode].pdf
PPTX
constructorsfjy5ediykEASFul;IUWORHusi;gfb.pptx
PPTX
Constructors and Destructors in C++.pptx
PPTX
Constructors and destructors
PPT
Constructors and destructors in C++
PDF
1.11 Constructors and Destructors....pdf
PPT
Constructor and destructor in C++
PPT
Constructors and destructors in C++ part 2
PPTX
constructor & destructor in cpp
PPTX
Constructor in c++
PDF
22 scheme OOPs with C++ BCS306B_module2.pdfmodule2.pdf
PPT
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
PPT
ConsTRUCTION AND DESTRUCTION
PPT
5 Constructors and Destructors
PPT
Oop Constructor Destructors Constructor Overloading lecture 2
Constructor
Constructor and desturctor
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
OOP-Lecture-05 (Constructor_Destructor).pptx
constructors and destructors
Constructors & Destructors [Compatibility Mode].pdf
constructorsfjy5ediykEASFul;IUWORHusi;gfb.pptx
Constructors and Destructors in C++.pptx
Constructors and destructors
Constructors and destructors in C++
1.11 Constructors and Destructors....pdf
Constructor and destructor in C++
Constructors and destructors in C++ part 2
constructor & destructor in cpp
Constructor in c++
22 scheme OOPs with C++ BCS306B_module2.pdfmodule2.pdf
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
ConsTRUCTION AND DESTRUCTION
5 Constructors and Destructors
Oop Constructor Destructors Constructor Overloading lecture 2

Recently uploaded (20)

PPTX
UNIT 4 Total Quality Management .pptx
PPT
introduction to datamining and warehousing
PPT
Total quality management ppt for engineering students
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Artificial Intelligence
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Sustainable Sites - Green Building Construction
PPTX
Geodesy 1.pptx...............................................
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
UNIT 4 Total Quality Management .pptx
introduction to datamining and warehousing
Total quality management ppt for engineering students
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Automation-in-Manufacturing-Chapter-Introduction.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Artificial Intelligence
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
III.4.1.2_The_Space_Environment.p pdffdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
additive manufacturing of ss316l using mig welding
Sustainable Sites - Green Building Construction
Geodesy 1.pptx...............................................
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf

Constructor and destructor