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

PDF
Constructor and Destructor
PPTX
[OOP - Lec 19] Static Member Functions
PPTX
07. Virtual Functions
PDF
Constructors and Destructors
PPT
Class and object in C++
PPTX
classes and objects in C++
PDF
Constructors and destructors
PPT
Function overloading(c++)
Constructor and Destructor
[OOP - Lec 19] Static Member Functions
07. Virtual Functions
Constructors and Destructors
Class and object in C++
classes and objects in C++
Constructors and destructors
Function overloading(c++)

What's hot (20)

PPTX
Function overloading
PPTX
Constructors in C++
PPTX
Pointers in c++
PPTX
INLINE FUNCTION IN C++
PPTX
This pointer
PPTX
Constructors and destructors
PPTX
Functions in C
PPTX
Constructor in java
PPTX
PPTX
Types of Constructor in C++
PPTX
PPT
friend function(c++)
PPTX
Static Data Members and Member Functions
PPTX
Inheritance in java
PPTX
Basic Data Types in C++
PPTX
Methods in java
PPTX
Inheritance in c++
PPTX
Classes, objects in JAVA
PPTX
Pointer in c
PPTX
Abstract class in c++
Function overloading
Constructors in C++
Pointers in c++
INLINE FUNCTION IN C++
This pointer
Constructors and destructors
Functions in C
Constructor in java
Types of Constructor in C++
friend function(c++)
Static Data Members and Member Functions
Inheritance in java
Basic Data Types in C++
Methods in java
Inheritance in c++
Classes, objects in JAVA
Pointer in c
Abstract class in c++
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
constructors and destructors
PPTX
CONSTRUCTORS, DESTRUCTORS AND OPERATOR OVERLOADING.pptx
PPTX
Constructors
PPT
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
PPTX
Constructor and desturctor
PDF
OOPs & Inheritance Notes
PPTX
Lecture 4.2 c++(comlete reference book)
PPTX
Constructors in C++.pptx
PDF
Session 3 Constructors, Types, Overloading, Static MethodsNotes.pdf
PPT
classes and constructors lec 03 & 04.ppt
PDF
22 scheme OOPs with C++ BCS306B_module2.pdfmodule2.pdf
PDF
classes and objects.pdfggggggggffffffffgggf
PPTX
Constructors and Destructors in C++.pptx
PDF
chapter-9-constructors.pdf
PDF
Intake 37 4
PDF
Constructors destructors
PPT
Java class
PPTX
Constructor in c++
PPT
Constructor,destructors cpp
PPTX
constructors.pptx
constructors and destructors
CONSTRUCTORS, DESTRUCTORS AND OPERATOR OVERLOADING.pptx
Constructors
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
Constructor and desturctor
OOPs & Inheritance Notes
Lecture 4.2 c++(comlete reference book)
Constructors in C++.pptx
Session 3 Constructors, Types, Overloading, Static MethodsNotes.pdf
classes and constructors lec 03 & 04.ppt
22 scheme OOPs with C++ BCS306B_module2.pdfmodule2.pdf
classes and objects.pdfggggggggffffffffgggf
Constructors and Destructors in C++.pptx
chapter-9-constructors.pdf
Intake 37 4
Constructors destructors
Java class
Constructor in c++
Constructor,destructors cpp
constructors.pptx

Recently uploaded (20)

PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPT
Project quality management in manufacturing
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
UNIT 4 Total Quality Management .pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Geodesy 1.pptx...............................................
PPTX
web development for engineering and engineering
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Project quality management in manufacturing
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Lesson 3_Tessellation.pptx finite Mathematics
Arduino robotics embedded978-1-4302-3184-4.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
UNIT 4 Total Quality Management .pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Lecture Notes Electrical Wiring System Components
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Mechanical Engineering MATERIALS Selection
bas. eng. economics group 4 presentation 1.pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Geodesy 1.pptx...............................................
web development for engineering and engineering

Constructor and destructor