SlideShare a Scribd company logo
1 of 4
Q1:
Ans: A constructorfunction is a special function that is a member of class and has
same name as that of class, to create and initialize object of the class.
1- Construction don’thave return type
2- Should be declared in public section.
Constructor:
Syntax:
class class_name
{
public:
class_name ();
};
Type of constructor:
1- Parameterized Constructor.
2- Overloaded constructor.
3- Constructorwith default argument.
4- Copyconstructor.
5- Dynamic constructor.
Destructor:
Destructor is the special function with same name as a class name with negation
sign, basically used to destroythe object.
1- Must be declared in public section
2- Don’t have return type and argument.
3- A class can have only one destructor.
Example:
class st
{
public:
negation sign st()
{
cout<<”Destructor”;
}
};
Q2:
Ans: default argument is the value that compiler himself automatically insert the
value you don’tneed to provide value to function call.
Two Rule
1- Trailing argument may be defaulted, that is , default argument using non
default argument.
2- Once you start using default argument in function call then all the
subsequent argument must be defaulted
Example:
Class st
{
Int num,num1;
Public:
St(int a,int b=0) //constructwith default argument };
Q3:
Ans: Yes, we can call constructorand destructor explicity.
following wil explain how constructorand destructorcalled explicity.
Example :
Class check
{
check(){cout<<”Any thing”;}
-check(){cout<<”Waooo”;}
};
main()
{
check();//explicit call to constructor
Check c;
c.-check();
return 0;
}
Q4:
Ans: Static Object:
An object is become static when static keyword is used before that
object.
For Example:
Test t;
Static test t;
Characteristics:
1- Static object initialized once and live until the program terminated.
2- Static object are allocated storage in static storage area.
3- Static object destroywhen program terminated.
Q5:
Parameterized constructor:
It may be necessary to initialize the various data element of different object
with different value when they are created. This achieved by passing argument to
the constructorfunction when the object are created.
in simple words constructorthat can take argument are called parameterized
constructors.

More Related Content

What's hot

What's hot (20)

vb.net Constructor and destructor
vb.net Constructor and destructorvb.net Constructor and destructor
vb.net Constructor and destructor
 
Constructor & destructor
Constructor & destructorConstructor & destructor
Constructor & destructor
 
Constructor and desturctor
Constructor and desturctorConstructor and desturctor
Constructor and desturctor
 
Inheritance
InheritanceInheritance
Inheritance
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
constructors in java ppt
constructors in java pptconstructors in java ppt
constructors in java ppt
 
Java Constructors
Java ConstructorsJava Constructors
Java Constructors
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
C++
C++C++
C++
 
Constructors
ConstructorsConstructors
Constructors
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Constructor
ConstructorConstructor
Constructor
 
Interfaces In Java
Interfaces In JavaInterfaces In Java
Interfaces In Java
 
Constructor&amp; destructor
Constructor&amp; destructorConstructor&amp; destructor
Constructor&amp; destructor
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
C# Constructors
C# ConstructorsC# Constructors
C# Constructors
 
Java interface
Java interfaceJava interface
Java interface
 
Oop Constructor Destructors Constructor Overloading lecture 2
Oop Constructor  Destructors Constructor Overloading lecture 2Oop Constructor  Destructors Constructor Overloading lecture 2
Oop Constructor Destructors Constructor Overloading lecture 2
 
Constructor and destructor in c++
Constructor and destructor in c++Constructor and destructor in c++
Constructor and destructor in c++
 
Constructor and Destructor PPT
Constructor and Destructor PPTConstructor and Destructor PPT
Constructor and Destructor PPT
 

Viewers also liked

Viewers also liked (20)

Procés tecnològic
Procés tecnològicProcés tecnològic
Procés tecnològic
 
My
MyMy
My
 
Presentazione Fidia spa
Presentazione Fidia spaPresentazione Fidia spa
Presentazione Fidia spa
 
Advertising production for television- presentation
Advertising production for television- presentationAdvertising production for television- presentation
Advertising production for television- presentation
 
Assigment 2
Assigment 2Assigment 2
Assigment 2
 
Pmmu são paulo - bicicletas
Pmmu são paulo - bicicletasPmmu são paulo - bicicletas
Pmmu são paulo - bicicletas
 
134367 20160212 - lai acompanhamento+anexo - lombadas santander
134367   20160212 - lai acompanhamento+anexo - lombadas santander134367   20160212 - lai acompanhamento+anexo - lombadas santander
134367 20160212 - lai acompanhamento+anexo - lombadas santander
 
Aparato locomotor (1)
Aparato locomotor (1)Aparato locomotor (1)
Aparato locomotor (1)
 
Shia and belief
Shia and beliefShia and belief
Shia and belief
 
Name
NameName
Name
 
Fol
FolFol
Fol
 
культура западной европы в раннее средневековье
культура западной европы в раннее средневековьекультура западной европы в раннее средневековье
культура западной европы в раннее средневековье
 
Gary Paul Smith - Living The User Experience
Gary Paul Smith - Living The User ExperienceGary Paul Smith - Living The User Experience
Gary Paul Smith - Living The User Experience
 
Akashi Brochure - General
Akashi Brochure - GeneralAkashi Brochure - General
Akashi Brochure - General
 
FNK rev 06.08.15
FNK rev 06.08.15FNK rev 06.08.15
FNK rev 06.08.15
 
Pat Good Results Analysis
Pat Good Results AnalysisPat Good Results Analysis
Pat Good Results Analysis
 
SOCIAL MEDIA
SOCIAL MEDIASOCIAL MEDIA
SOCIAL MEDIA
 
Will Good Conclusion
Will Good ConclusionWill Good Conclusion
Will Good Conclusion
 
Foot locker challenge
Foot locker challengeFoot locker challenge
Foot locker challenge
 
Lymphatic system
Lymphatic systemLymphatic system
Lymphatic system
 

Similar to Constructor Destructor

Similar to Constructor Destructor (20)

C++
C++C++
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
 
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
 
C++ Constructor destructor
C++ Constructor destructorC++ Constructor destructor
C++ Constructor destructor
 
Destructors
DestructorsDestructors
Destructors
 
Constructor and Destructor in c++
Constructor  and Destructor in c++Constructor  and Destructor in c++
Constructor and Destructor in c++
 
Oops
OopsOops
Oops
 
Learning C++ - Class 4
Learning C++ - Class 4Learning C++ - Class 4
Learning C++ - Class 4
 
Constructors & Destructors
Constructors  & DestructorsConstructors  & Destructors
Constructors & Destructors
 
Constructor & Destructor
Constructor & DestructorConstructor & Destructor
Constructor & Destructor
 
Constructors in C++.pptx
Constructors in C++.pptxConstructors in C++.pptx
Constructors in C++.pptx
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
Class and object
Class and objectClass and object
Class and object
 
Constructors
ConstructorsConstructors
Constructors
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects new
 
ConsTRUCTION AND DESTRUCTION
ConsTRUCTION AND DESTRUCTIONConsTRUCTION AND DESTRUCTION
ConsTRUCTION AND DESTRUCTION
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
 
03class
03class03class
03class
 

Recently uploaded

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 

Recently uploaded (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 

Constructor Destructor

  • 1. Q1: Ans: A constructorfunction is a special function that is a member of class and has same name as that of class, to create and initialize object of the class. 1- Construction don’thave return type 2- Should be declared in public section. Constructor: Syntax: class class_name { public: class_name (); }; Type of constructor: 1- Parameterized Constructor. 2- Overloaded constructor. 3- Constructorwith default argument. 4- Copyconstructor. 5- Dynamic constructor. Destructor: Destructor is the special function with same name as a class name with negation sign, basically used to destroythe object. 1- Must be declared in public section 2- Don’t have return type and argument. 3- A class can have only one destructor.
  • 2. Example: class st { public: negation sign st() { cout<<”Destructor”; } }; Q2: Ans: default argument is the value that compiler himself automatically insert the value you don’tneed to provide value to function call. Two Rule 1- Trailing argument may be defaulted, that is , default argument using non default argument. 2- Once you start using default argument in function call then all the subsequent argument must be defaulted Example: Class st { Int num,num1; Public: St(int a,int b=0) //constructwith default argument };
  • 3. Q3: Ans: Yes, we can call constructorand destructor explicity. following wil explain how constructorand destructorcalled explicity. Example : Class check { check(){cout<<”Any thing”;} -check(){cout<<”Waooo”;} }; main() { check();//explicit call to constructor Check c; c.-check(); return 0; } Q4: Ans: Static Object: An object is become static when static keyword is used before that object.
  • 4. For Example: Test t; Static test t; Characteristics: 1- Static object initialized once and live until the program terminated. 2- Static object are allocated storage in static storage area. 3- Static object destroywhen program terminated. Q5: Parameterized constructor: It may be necessary to initialize the various data element of different object with different value when they are created. This achieved by passing argument to the constructorfunction when the object are created. in simple words constructorthat can take argument are called parameterized constructors.