SlideShare ist ein Scribd-Unternehmen logo
1 von 7
CONSTUCTOR & DESTRUCTORSCONSTUCTOR & DESTRUCTORS
OBJECT ORIENTED PROGRAMMINGOBJECT ORIENTED PROGRAMMING
INDEX
Concept of constructor, types of constructorConcept of constructor, types of constructor
Overloaded constructor
Destructor
1
2
3
CONCEPT OF CONSTRUCTOR
• A constructor is a special member function
whose task is to initialize the objects of that
class.
• It is special because its name is the same as
the class name.
• Constructor is invoked whenever an object of
the associated class is created.
• It is called constructor because it constructs
the values of data members of the class.
TYPES OF CONSTRUCTOR
• Default constructor:
A constructor that accepts no parameters is called
the default constructor.
• Parameterized constructor:
The constructor that can take arguments is called as
parameterized constructor.
• Copy constructor:
a constructor can accept a reference to its own class
as a parameter which is called as copy constructor.
OVERLOADED CONSTRUCTOR
• When more than one constructor function is
defined in a class, we say the constructor is
overloaded.
DESTRUCTOR
• A destructor, as the name implies is used to
destroy the objects that have been created by
a constructor.
• Like a constructor, the destructor is also a
special member function whose name is the
same as the class name but is preceded by a
tilde(~).
• Example: the destructor for class integer can
be defined as shown below
~integer() {}
DESTRUCTOR
• A destructor, as the name implies is used to
destroy the objects that have been created by
a constructor.
• Like a constructor, the destructor is also a
special member function whose name is the
same as the class name but is preceded by a
tilde(~).
• Example: the destructor for class integer can
be defined as shown below
~integer() {}

Weitere ähnliche Inhalte

Was ist angesagt?

Structures in c++
Structures in c++Structures in c++
Structures in c++Swarup Boro
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in javaHitesh Kumar
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructorsNilesh Dalvi
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overridingRajab Ali
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingAmit Soni (CTFL)
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++Muhammad Waqas
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmigAppili Vamsi Krishna
 
OOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyOOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyMudasir Qazi
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++Sujan Mia
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQLrehaniltifat
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streamsbabak danyal
 
Java Data Types
Java Data TypesJava Data Types
Java Data TypesSpotle.ai
 
C++ Returning Objects
C++ Returning ObjectsC++ Returning Objects
C++ Returning ObjectsJay Patel
 
SPL 1 | Introduction to Structured programming language
SPL 1 | Introduction to Structured programming languageSPL 1 | Introduction to Structured programming language
SPL 1 | Introduction to Structured programming languageMohammad Imam Hossain
 

Was ist angesagt? (20)

Structures in c++
Structures in c++Structures in c++
Structures in c++
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
 
Scanner class
Scanner classScanner class
Scanner class
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Encapsulation C++
Encapsulation C++Encapsulation C++
Encapsulation C++
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmig
 
OOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyOOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependency
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
 
Methods in C#
Methods in C#Methods in C#
Methods in C#
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
C++ Returning Objects
C++ Returning ObjectsC++ Returning Objects
C++ Returning Objects
 
SPL 1 | Introduction to Structured programming language
SPL 1 | Introduction to Structured programming languageSPL 1 | Introduction to Structured programming language
SPL 1 | Introduction to Structured programming language
 

Ähnlich wie constructor and destructor-object oriented programming

C++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptxC++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptxsasukeman
 
Constructor and destructor in oop
Constructor and destructor in oop Constructor and destructor in oop
Constructor and destructor in oop Samad Qazi
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and DestructorSunipa Bera
 
Constructor and Destructor in c++
Constructor  and Destructor in c++Constructor  and Destructor in c++
Constructor and Destructor in c++aleenaguen
 
Constructors in java
Constructors in javaConstructors in java
Constructors in javasunilchute1
 
Constructor and destructor
Constructor and destructorConstructor and destructor
Constructor and destructorrajshreemuthiah
 
Constructor and desturctor
Constructor and desturctorConstructor and desturctor
Constructor and desturctorSomnath Kulkarni
 
Constructor & destructor
Constructor & destructorConstructor & destructor
Constructor & destructorSaharsh Anand
 
C++ Constructor destructor
C++ Constructor destructorC++ Constructor destructor
C++ Constructor destructorDa Mystic Sadi
 
What is Constructors and Destructors in C++ (Explained with Example along wi...
What is Constructors and Destructors in  C++ (Explained with Example along wi...What is Constructors and Destructors in  C++ (Explained with Example along wi...
What is Constructors and Destructors in C++ (Explained with Example along wi...Pallavi Seth
 
Java ConstructorsPPT.pptx
Java ConstructorsPPT.pptxJava ConstructorsPPT.pptx
Java ConstructorsPPT.pptxXanGwaps
 

Ähnlich wie constructor and destructor-object oriented programming (20)

Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
C++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptxC++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptx
 
Constructor and destructor in oop
Constructor and destructor in oop Constructor and destructor in oop
Constructor and destructor in oop
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Constructor and Destructor in c++
Constructor  and Destructor in c++Constructor  and Destructor in c++
Constructor and Destructor in c++
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Constructors in java
Constructors in javaConstructors in java
Constructors in java
 
Constructor and destructor
Constructor and destructorConstructor and destructor
Constructor and destructor
 
Constructors & Destructors
Constructors  & DestructorsConstructors  & Destructors
Constructors & Destructors
 
Constructor and desturctor
Constructor and desturctorConstructor and desturctor
Constructor and desturctor
 
DHARANI.pptx
DHARANI.pptxDHARANI.pptx
DHARANI.pptx
 
Constructor & destructor
Constructor & destructorConstructor & destructor
Constructor & destructor
 
C++ Constructor destructor
C++ Constructor destructorC++ Constructor destructor
C++ Constructor destructor
 
What is Constructors and Destructors in C++ (Explained with Example along wi...
What is Constructors and Destructors in  C++ (Explained with Example along wi...What is Constructors and Destructors in  C++ (Explained with Example along wi...
What is Constructors and Destructors in C++ (Explained with Example along wi...
 
Java ConstructorsPPT.pptx
Java ConstructorsPPT.pptxJava ConstructorsPPT.pptx
Java ConstructorsPPT.pptx
 
Constructor
ConstructorConstructor
Constructor
 
C++
C++C++
C++
 
C++
C++C++
C++
 
constructor.ppt
constructor.pptconstructor.ppt
constructor.ppt
 

Mehr von Ashita Agrawal

Linux operating system - Overview
Linux operating system - OverviewLinux operating system - Overview
Linux operating system - OverviewAshita Agrawal
 
Introductio to Abstract Window Toolkit (AWT)
Introductio to Abstract Window Toolkit (AWT)Introductio to Abstract Window Toolkit (AWT)
Introductio to Abstract Window Toolkit (AWT)Ashita Agrawal
 
Inheritance in Object Oriented Programming
Inheritance in Object Oriented ProgrammingInheritance in Object Oriented Programming
Inheritance in Object Oriented ProgrammingAshita Agrawal
 
INTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMSINTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMSAshita Agrawal
 
Biography of Mahatma Gandhi : 1869-1948
Biography of Mahatma Gandhi : 1869-1948Biography of Mahatma Gandhi : 1869-1948
Biography of Mahatma Gandhi : 1869-1948Ashita Agrawal
 
Cloud computing - new class of network based computing
Cloud computing - new class of network based computingCloud computing - new class of network based computing
Cloud computing - new class of network based computingAshita Agrawal
 
Introduction to computer network
Introduction to computer networkIntroduction to computer network
Introduction to computer networkAshita Agrawal
 
Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorAshita Agrawal
 
Testing Machine- universal tester
Testing Machine- universal testerTesting Machine- universal tester
Testing Machine- universal testerAshita Agrawal
 
Adolf Hitler - German politician(world war I)
Adolf Hitler - German politician(world war I)Adolf Hitler - German politician(world war I)
Adolf Hitler - German politician(world war I)Ashita Agrawal
 
Charles babbage - Father of Computing.
Charles babbage - Father of Computing. Charles babbage - Father of Computing.
Charles babbage - Father of Computing. Ashita Agrawal
 
Ada Lovelace-The First Programmer
Ada Lovelace-The First ProgrammerAda Lovelace-The First Programmer
Ada Lovelace-The First ProgrammerAshita Agrawal
 

Mehr von Ashita Agrawal (17)

Linux operating system - Overview
Linux operating system - OverviewLinux operating system - Overview
Linux operating system - Overview
 
Introductio to Abstract Window Toolkit (AWT)
Introductio to Abstract Window Toolkit (AWT)Introductio to Abstract Window Toolkit (AWT)
Introductio to Abstract Window Toolkit (AWT)
 
Inheritance in Object Oriented Programming
Inheritance in Object Oriented ProgrammingInheritance in Object Oriented Programming
Inheritance in Object Oriented Programming
 
INTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMSINTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMS
 
Introduction to Sets
Introduction to SetsIntroduction to Sets
Introduction to Sets
 
Business Overview
Business OverviewBusiness Overview
Business Overview
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Biography of Mahatma Gandhi : 1869-1948
Biography of Mahatma Gandhi : 1869-1948Biography of Mahatma Gandhi : 1869-1948
Biography of Mahatma Gandhi : 1869-1948
 
Cloud computing - new class of network based computing
Cloud computing - new class of network based computingCloud computing - new class of network based computing
Cloud computing - new class of network based computing
 
Introduction to computer network
Introduction to computer networkIntroduction to computer network
Introduction to computer network
 
Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 Microprocessor
 
Testing Machine- universal tester
Testing Machine- universal testerTesting Machine- universal tester
Testing Machine- universal tester
 
Adolf Hitler - German politician(world war I)
Adolf Hitler - German politician(world war I)Adolf Hitler - German politician(world war I)
Adolf Hitler - German politician(world war I)
 
Charles babbage - Father of Computing.
Charles babbage - Father of Computing. Charles babbage - Father of Computing.
Charles babbage - Father of Computing.
 
Ada Lovelace-The First Programmer
Ada Lovelace-The First ProgrammerAda Lovelace-The First Programmer
Ada Lovelace-The First Programmer
 
Slums In India
Slums In IndiaSlums In India
Slums In India
 
Augmented Reality
Augmented RealityAugmented Reality
Augmented Reality
 

Kürzlich hochgeladen

Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfRajuKanojiya4
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Internet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxInternet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxVelmuruganTECE
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...Amil Baba Dawood bangali
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 

Kürzlich hochgeladen (20)

Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdf
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Internet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxInternet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptx
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 

constructor and destructor-object oriented programming

  • 1. CONSTUCTOR & DESTRUCTORSCONSTUCTOR & DESTRUCTORS OBJECT ORIENTED PROGRAMMINGOBJECT ORIENTED PROGRAMMING
  • 2. INDEX Concept of constructor, types of constructorConcept of constructor, types of constructor Overloaded constructor Destructor 1 2 3
  • 3. CONCEPT OF CONSTRUCTOR • A constructor is a special member function whose task is to initialize the objects of that class. • It is special because its name is the same as the class name. • Constructor is invoked whenever an object of the associated class is created. • It is called constructor because it constructs the values of data members of the class.
  • 4. TYPES OF CONSTRUCTOR • Default constructor: A constructor that accepts no parameters is called the default constructor. • Parameterized constructor: The constructor that can take arguments is called as parameterized constructor. • Copy constructor: a constructor can accept a reference to its own class as a parameter which is called as copy constructor.
  • 5. OVERLOADED CONSTRUCTOR • When more than one constructor function is defined in a class, we say the constructor is overloaded.
  • 6. DESTRUCTOR • A destructor, as the name implies is used to destroy the objects that have been created by a constructor. • Like a constructor, the destructor is also a special member function whose name is the same as the class name but is preceded by a tilde(~). • Example: the destructor for class integer can be defined as shown below ~integer() {}
  • 7. DESTRUCTOR • A destructor, as the name implies is used to destroy the objects that have been created by a constructor. • Like a constructor, the destructor is also a special member function whose name is the same as the class name but is preceded by a tilde(~). • Example: the destructor for class integer can be defined as shown below ~integer() {}