SlideShare a Scribd company logo
1 of 12
BY
T.DEEPIKA M.SC(INFO TECH)
NADAR SARASWATHI COLLEGE OF ARTS
ANDSCIENCE
What is destructor?
 A destructor is a special member function that is
called when the lifetime of an object ends.
 The purpose of the destructor is to free the resources
that the object may have acquired during its lifetime.
DEFINITION OF DESTRUCTOR:
A Destructor is used to destroy the objects
that have been created by constructor.
Like a constructor the destructor is a
member function whose name is the same
as the class name but is preceded by a
tilde.
FOR EXAMPLE:
The destructor for the class integer can be
Tell in or defined in
~integer(){}
• We define the destructor by the symbol
“TILDE”(~).
A Destructor never takes any arguments
nor does it return any value
Destructor are mainly used for in future
use for memory space.
• Implicitly by the complier exit from the
program to clean up storage that is for no
longer accessible.
• In constructor allocate the memory by
using “new” and “delete” used to delete
memory.
PROGRAM LOGIC:
Matrix::~matrix()
{
For(int i=0;i<d1;i++)
Delete p(i);
Delete p;
}
A Destructor is not called implicitly.
Destructor mainly used for destroy the
object.
Destructor in c++:
 A destructor is called for a class object when that
object passes out of scope or is explicitly deleted
 It is mainly used for deallocate memory and clean up
the class object and its class members.
C++
 A destructor is a special method called automatically
during the destruction of an object.
 Actions executed in the destructor include the following:
 Recovering the heap space allocated during the lifetime of
an object.
 Closing file or database connections.
 Releasing network resources.
Overload destructor
 Destructor is mainly used to delete the object
and so only one time to call destructor when the
overloading is not occur
 Destructor it needs to call when you destroy an
object
What is a destructor in C

More Related Content

What's hot (20)

Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Constructors and Destructor in C++
Constructors and Destructor in C++Constructors and Destructor in C++
Constructors and Destructor in C++
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
[OOP - Lec 07] Access Specifiers
[OOP - Lec 07] Access Specifiers[OOP - Lec 07] Access Specifiers
[OOP - Lec 07] Access Specifiers
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloading
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and Packages
 
Input output streams
Input output streamsInput output streams
Input output streams
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 

Similar to What is a destructor in C

Similar to What is a destructor in C (20)

Constructor and Destructor in c++
Constructor  and Destructor in c++Constructor  and Destructor in c++
Constructor and Destructor in c++
 
Constructor and destructor in C++
Constructor and destructor in C++Constructor and destructor in C++
Constructor and destructor in C++
 
Constructors and destructors in C++ part 2
Constructors and destructors in C++ part 2Constructors and destructors in C++ part 2
Constructors and destructors in C++ part 2
 
Constructors in C++.pptx
Constructors in C++.pptxConstructors in C++.pptx
Constructors in C++.pptx
 
Destructer
DestructerDestructer
Destructer
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
C++ Unit-III Lecture-3a-C++ Programming Concepts
C++ Unit-III Lecture-3a-C++ Programming ConceptsC++ Unit-III Lecture-3a-C++ Programming Concepts
C++ Unit-III Lecture-3a-C++ Programming Concepts
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
26c
26c26c
26c
 
26csharp
26csharp26csharp
26csharp
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects new
 
Constructor and desturctor
Constructor and desturctorConstructor and desturctor
Constructor and desturctor
 
Constructor,destructors cpp
Constructor,destructors cppConstructor,destructors cpp
Constructor,destructors cpp
 
Constructor & destructor
Constructor & destructorConstructor & destructor
Constructor & destructor
 
C++ classes
C++ classesC++ classes
C++ classes
 
Constructors & Destructors
Constructors  & DestructorsConstructors  & Destructors
Constructors & Destructors
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Destructors
DestructorsDestructors
Destructors
 
advance-dart.pptx
advance-dart.pptxadvance-dart.pptx
advance-dart.pptx
 
object oriented programming language by c++
object oriented programming language by c++object oriented programming language by c++
object oriented programming language by c++
 

More from DeepikaT13

Mobile computing
Mobile computingMobile computing
Mobile computingDeepikaT13
 
Image processing
Image processingImage processing
Image processingDeepikaT13
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filteringDeepikaT13
 
Hive architecture
Hive  architectureHive  architecture
Hive architectureDeepikaT13
 
Sotware engineering
Sotware engineeringSotware engineering
Sotware engineeringDeepikaT13
 
Computer network
Computer networkComputer network
Computer networkDeepikaT13
 
Storage management in operating system
Storage management in operating systemStorage management in operating system
Storage management in operating systemDeepikaT13
 
Neural network
Neural networkNeural network
Neural networkDeepikaT13
 
memory reference instruction
memory reference instructionmemory reference instruction
memory reference instructionDeepikaT13
 
breadth first search
breadth first searchbreadth first search
breadth first searchDeepikaT13
 
Computer registers
Computer registersComputer registers
Computer registersDeepikaT13
 

More from DeepikaT13 (20)

Mobile computing
Mobile computingMobile computing
Mobile computing
 
Image processing
Image processingImage processing
Image processing
 
aloha
alohaaloha
aloha
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 
Exceptions
ExceptionsExceptions
Exceptions
 
Hive architecture
Hive  architectureHive  architecture
Hive architecture
 
Rdbms
RdbmsRdbms
Rdbms
 
Sotware engineering
Sotware engineeringSotware engineering
Sotware engineering
 
Data mining
Data miningData mining
Data mining
 
Computer network
Computer networkComputer network
Computer network
 
Storage management in operating system
Storage management in operating systemStorage management in operating system
Storage management in operating system
 
Jdbc
JdbcJdbc
Jdbc
 
Data mining
Data miningData mining
Data mining
 
Neural network
Neural networkNeural network
Neural network
 
memory reference instruction
memory reference instructionmemory reference instruction
memory reference instruction
 
breadth first search
breadth first searchbreadth first search
breadth first search
 
constructors
constructorsconstructors
constructors
 
Disjoint set
Disjoint setDisjoint set
Disjoint set
 
Crisp set
Crisp setCrisp set
Crisp set
 
Computer registers
Computer registersComputer registers
Computer registers
 

Recently uploaded

MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 

Recently uploaded (20)

ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 

What is a destructor in C

  • 1. BY T.DEEPIKA M.SC(INFO TECH) NADAR SARASWATHI COLLEGE OF ARTS ANDSCIENCE
  • 2. What is destructor?  A destructor is a special member function that is called when the lifetime of an object ends.  The purpose of the destructor is to free the resources that the object may have acquired during its lifetime.
  • 3. DEFINITION OF DESTRUCTOR: A Destructor is used to destroy the objects that have been created by constructor. Like a constructor the destructor is a member function whose name is the same as the class name but is preceded by a tilde.
  • 4. FOR EXAMPLE: The destructor for the class integer can be Tell in or defined in ~integer(){} • We define the destructor by the symbol “TILDE”(~).
  • 5. A Destructor never takes any arguments nor does it return any value Destructor are mainly used for in future use for memory space.
  • 6. • Implicitly by the complier exit from the program to clean up storage that is for no longer accessible. • In constructor allocate the memory by using “new” and “delete” used to delete memory.
  • 8. A Destructor is not called implicitly. Destructor mainly used for destroy the object.
  • 9. Destructor in c++:  A destructor is called for a class object when that object passes out of scope or is explicitly deleted  It is mainly used for deallocate memory and clean up the class object and its class members.
  • 10. C++  A destructor is a special method called automatically during the destruction of an object.  Actions executed in the destructor include the following:  Recovering the heap space allocated during the lifetime of an object.  Closing file or database connections.  Releasing network resources.
  • 11. Overload destructor  Destructor is mainly used to delete the object and so only one time to call destructor when the overloading is not occur  Destructor it needs to call when you destroy an object