SlideShare a Scribd company logo
1 of 3
Provide copy constructor, destructor, and assignment operator for the IntList class that stores a
collection of integers using linked list.
class ListNode {
int value;
ListNode * next;
};
class IntList {
public: ...
IntList(const IntList & other);
~IntList();
IntList& operator =( const IntList & other ) ...
private:
int num; //the number of ints stored.
ListNode * first;
};
Solution
Hi, I have implemented all functionality.
Please test it in your test program
using namespace std;
class ListNode {
public:
int value;
ListNode * next;
};
class IntList {
public:
IntList();
IntList(const IntList & other);
~IntList();
void operator =( const IntList & other);
private:
int num; //the number of ints stored.
ListNode * first;
};
IntList::IntList(const IntList & other){
IntList *ptr = new IntList();
ListNode *temp = other.first;
ListNode *temp1 = ptr->first;
ListNode *firstLocal = NULL;
while(temp != NULL){
if(firstLocal == NULL){
firstLocal = temp;
temp1 = firstLocal;
}
else{
temp1->next = temp;
temp1 = temp;
}
temp = temp->next;
}
ptr->first = firstLocal;
ptr->num = other.num;
}
IntList::~IntList(){
while(first != NULL){
ListNode *local = first;
first = first->next;
delete local;
}
}
IntList::IntList(){
first = NULL;
num = 0;
}
void IntList::operator =( const IntList & other){
first = other.first;
num = other.num;
}

More Related Content

Similar to Implement copy constructor, destructor, and assignment operator for linked list class

lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxDIPESH30
 
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfmail931892
 
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdfarshin9
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfarorastores
 
IN C CODEGiven an IntNode struct and the operating functions for a.pdf
IN C CODEGiven an IntNode struct and the operating functions for a.pdfIN C CODEGiven an IntNode struct and the operating functions for a.pdf
IN C CODEGiven an IntNode struct and the operating functions for a.pdfsiva009113
 
Write a program that will test a name) method no sorting routine from.docx
 Write a program that will test a name) method no sorting routine from.docx Write a program that will test a name) method no sorting routine from.docx
Write a program that will test a name) method no sorting routine from.docxajoy21
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdfakkhan101
 
Main-cpp #include -iostream- #include -List-h- int main() { retur.pdf
Main-cpp  #include -iostream- #include -List-h- int main() {     retur.pdfMain-cpp  #include -iostream- #include -List-h- int main() {     retur.pdf
Main-cpp #include -iostream- #include -List-h- int main() { retur.pdfPeterM9sWhitej
 
maincpp include ListItemh include ltstringgt in.pdf
maincpp include ListItemh include ltstringgt in.pdfmaincpp include ListItemh include ltstringgt in.pdf
maincpp include ListItemh include ltstringgt in.pdfabiwarmaa
 
My question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdfMy question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdfjeetumordhani
 
Given an IntNode struct and the operating functions for a linked list-.pdf
Given an IntNode struct and the operating functions for a linked list-.pdfGiven an IntNode struct and the operating functions for a linked list-.pdf
Given an IntNode struct and the operating functions for a linked list-.pdfNicholasflqStewartl
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdffreddysarabia1
 
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdfCopy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdffacevenky
 
Array based based implementation of the List ADT It uses an array o.pdf
Array based based implementation of the List ADT It uses an array o.pdfArray based based implementation of the List ADT It uses an array o.pdf
Array based based implementation of the List ADT It uses an array o.pdfanithacells
 
Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyworldchannel
 
Java Programming- 1) Write a recursive method that finds and returns t.docx
Java Programming- 1) Write a recursive method that finds and returns t.docxJava Programming- 1) Write a recursive method that finds and returns t.docx
Java Programming- 1) Write a recursive method that finds and returns t.docxmichael1810
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfnaslin841216
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfRAJATCHUGH12
 
Coding convention
Coding conventionCoding convention
Coding conventionKhoa Nguyen
 

Similar to Implement copy constructor, destructor, and assignment operator for linked list class (20)

lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
 
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
 
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
 
IN C CODEGiven an IntNode struct and the operating functions for a.pdf
IN C CODEGiven an IntNode struct and the operating functions for a.pdfIN C CODEGiven an IntNode struct and the operating functions for a.pdf
IN C CODEGiven an IntNode struct and the operating functions for a.pdf
 
Write a program that will test a name) method no sorting routine from.docx
 Write a program that will test a name) method no sorting routine from.docx Write a program that will test a name) method no sorting routine from.docx
Write a program that will test a name) method no sorting routine from.docx
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
Main-cpp #include -iostream- #include -List-h- int main() { retur.pdf
Main-cpp  #include -iostream- #include -List-h- int main() {     retur.pdfMain-cpp  #include -iostream- #include -List-h- int main() {     retur.pdf
Main-cpp #include -iostream- #include -List-h- int main() { retur.pdf
 
maincpp include ListItemh include ltstringgt in.pdf
maincpp include ListItemh include ltstringgt in.pdfmaincpp include ListItemh include ltstringgt in.pdf
maincpp include ListItemh include ltstringgt in.pdf
 
My question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdfMy question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdf
 
Given an IntNode struct and the operating functions for a linked list-.pdf
Given an IntNode struct and the operating functions for a linked list-.pdfGiven an IntNode struct and the operating functions for a linked list-.pdf
Given an IntNode struct and the operating functions for a linked list-.pdf
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
 
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdfCopy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
 
Array based based implementation of the List ADT It uses an array o.pdf
Array based based implementation of the List ADT It uses an array o.pdfArray based based implementation of the List ADT It uses an array o.pdf
Array based based implementation of the List ADT It uses an array o.pdf
 
Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technology
 
Java Programming- 1) Write a recursive method that finds and returns t.docx
Java Programming- 1) Write a recursive method that finds and returns t.docxJava Programming- 1) Write a recursive method that finds and returns t.docx
Java Programming- 1) Write a recursive method that finds and returns t.docx
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdf
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
 
Coding convention
Coding conventionCoding convention
Coding convention
 

More from todd921

Question 1 2 points Save Team building is designed to gather.docx
Question 1  2  points    Save    Team  building is designed to gather.docxQuestion 1  2  points    Save    Team  building is designed to gather.docx
Question 1 2 points Save Team building is designed to gather.docxtodd921
 
Question 21 2 points Save How do training and development with.docx
Question  21  2 points   Save    How do training and development with.docxQuestion  21  2 points   Save    How do training and development with.docx
Question 21 2 points Save How do training and development with.docxtodd921
 
QS# 2- 9-17 What is the difference between a note payable and an accou.docx
QS# 2- 9-17 What is the difference between a note payable and an accou.docxQS# 2- 9-17 What is the difference between a note payable and an accou.docx
QS# 2- 9-17 What is the difference between a note payable and an accou.docxtodd921
 
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docx
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docxQ1) Prepare the year end closing entries for eagles corp- Q2) what is.docx
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docxtodd921
 
Q- Lord Rutherford found that most of an atom consists of empty space-.docx
Q- Lord Rutherford found that most of an atom consists of empty space-.docxQ- Lord Rutherford found that most of an atom consists of empty space-.docx
Q- Lord Rutherford found that most of an atom consists of empty space-.docxtodd921
 
PYTHON Programming Language Design a class named Account that contains.docx
PYTHON Programming Language Design a class named Account that contains.docxPYTHON Programming Language Design a class named Account that contains.docx
PYTHON Programming Language Design a class named Account that contains.docxtodd921
 
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docx
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docxPurchases Date Units Unit Cost Sales Units Average cost for each unit.docx
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docxtodd921
 
Provide examples of applications that typically access files according.docx
Provide examples of applications that typically access files according.docxProvide examples of applications that typically access files according.docx
Provide examples of applications that typically access files according.docxtodd921
 
Provide a summary of the basic ideals and significant individuals behi.docx
Provide a summary of the basic ideals and significant individuals behi.docxProvide a summary of the basic ideals and significant individuals behi.docx
Provide a summary of the basic ideals and significant individuals behi.docxtodd921
 
proposed solution to resource sharing and security against unauthorize.docx
proposed solution to resource sharing and security against unauthorize.docxproposed solution to resource sharing and security against unauthorize.docx
proposed solution to resource sharing and security against unauthorize.docxtodd921
 
Programming Language- C++ or Java Write to program to generate a pair.docx
Programming Language- C++ or Java Write to program to generate a pair.docxProgramming Language- C++ or Java Write to program to generate a pair.docx
Programming Language- C++ or Java Write to program to generate a pair.docxtodd921
 
Question 30 As people become more powerful they tend to become less go.docx
Question 30 As people become more powerful they tend to become less go.docxQuestion 30 As people become more powerful they tend to become less go.docx
Question 30 As people become more powerful they tend to become less go.docxtodd921
 
Question 34 People with high Machiavellian values tend to- place a lot.docx
Question 34 People with high Machiavellian values tend to- place a lot.docxQuestion 34 People with high Machiavellian values tend to- place a lot.docx
Question 34 People with high Machiavellian values tend to- place a lot.docxtodd921
 
Question 21 Resource scarcity is a likely cause of conflict in organiz.docx
Question 21 Resource scarcity is a likely cause of conflict in organiz.docxQuestion 21 Resource scarcity is a likely cause of conflict in organiz.docx
Question 21 Resource scarcity is a likely cause of conflict in organiz.docxtodd921
 
Question 2 Compare the eye to a camera by listing four of the basic co.docx
Question 2 Compare the eye to a camera by listing four of the basic co.docxQuestion 2 Compare the eye to a camera by listing four of the basic co.docx
Question 2 Compare the eye to a camera by listing four of the basic co.docxtodd921
 
Question 1- The alien species has decided that they will use a special.docx
Question 1- The alien species has decided that they will use a special.docxQuestion 1- The alien species has decided that they will use a special.docx
Question 1- The alien species has decided that they will use a special.docxtodd921
 
Question 13 Which of the following is the first stage of an experienti.docx
Question 13 Which of the following is the first stage of an experienti.docxQuestion 13 Which of the following is the first stage of an experienti.docx
Question 13 Which of the following is the first stage of an experienti.docxtodd921
 
Question 11 Active communication occurs by facial expressions- body po.docx
Question 11 Active communication occurs by facial expressions- body po.docxQuestion 11 Active communication occurs by facial expressions- body po.docx
Question 11 Active communication occurs by facial expressions- body po.docxtodd921
 
QUESTION 1 Interaction Design is designing interactive products to sup.docx
QUESTION 1 Interaction Design is designing interactive products to sup.docxQUESTION 1 Interaction Design is designing interactive products to sup.docx
QUESTION 1 Interaction Design is designing interactive products to sup.docxtodd921
 
question 1 What is the behavior of setting C locale- Strings are alway.docx
question 1 What is the behavior of setting C locale- Strings are alway.docxquestion 1 What is the behavior of setting C locale- Strings are alway.docx
question 1 What is the behavior of setting C locale- Strings are alway.docxtodd921
 

More from todd921 (20)

Question 1 2 points Save Team building is designed to gather.docx
Question 1  2  points    Save    Team  building is designed to gather.docxQuestion 1  2  points    Save    Team  building is designed to gather.docx
Question 1 2 points Save Team building is designed to gather.docx
 
Question 21 2 points Save How do training and development with.docx
Question  21  2 points   Save    How do training and development with.docxQuestion  21  2 points   Save    How do training and development with.docx
Question 21 2 points Save How do training and development with.docx
 
QS# 2- 9-17 What is the difference between a note payable and an accou.docx
QS# 2- 9-17 What is the difference between a note payable and an accou.docxQS# 2- 9-17 What is the difference between a note payable and an accou.docx
QS# 2- 9-17 What is the difference between a note payable and an accou.docx
 
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docx
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docxQ1) Prepare the year end closing entries for eagles corp- Q2) what is.docx
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docx
 
Q- Lord Rutherford found that most of an atom consists of empty space-.docx
Q- Lord Rutherford found that most of an atom consists of empty space-.docxQ- Lord Rutherford found that most of an atom consists of empty space-.docx
Q- Lord Rutherford found that most of an atom consists of empty space-.docx
 
PYTHON Programming Language Design a class named Account that contains.docx
PYTHON Programming Language Design a class named Account that contains.docxPYTHON Programming Language Design a class named Account that contains.docx
PYTHON Programming Language Design a class named Account that contains.docx
 
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docx
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docxPurchases Date Units Unit Cost Sales Units Average cost for each unit.docx
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docx
 
Provide examples of applications that typically access files according.docx
Provide examples of applications that typically access files according.docxProvide examples of applications that typically access files according.docx
Provide examples of applications that typically access files according.docx
 
Provide a summary of the basic ideals and significant individuals behi.docx
Provide a summary of the basic ideals and significant individuals behi.docxProvide a summary of the basic ideals and significant individuals behi.docx
Provide a summary of the basic ideals and significant individuals behi.docx
 
proposed solution to resource sharing and security against unauthorize.docx
proposed solution to resource sharing and security against unauthorize.docxproposed solution to resource sharing and security against unauthorize.docx
proposed solution to resource sharing and security against unauthorize.docx
 
Programming Language- C++ or Java Write to program to generate a pair.docx
Programming Language- C++ or Java Write to program to generate a pair.docxProgramming Language- C++ or Java Write to program to generate a pair.docx
Programming Language- C++ or Java Write to program to generate a pair.docx
 
Question 30 As people become more powerful they tend to become less go.docx
Question 30 As people become more powerful they tend to become less go.docxQuestion 30 As people become more powerful they tend to become less go.docx
Question 30 As people become more powerful they tend to become less go.docx
 
Question 34 People with high Machiavellian values tend to- place a lot.docx
Question 34 People with high Machiavellian values tend to- place a lot.docxQuestion 34 People with high Machiavellian values tend to- place a lot.docx
Question 34 People with high Machiavellian values tend to- place a lot.docx
 
Question 21 Resource scarcity is a likely cause of conflict in organiz.docx
Question 21 Resource scarcity is a likely cause of conflict in organiz.docxQuestion 21 Resource scarcity is a likely cause of conflict in organiz.docx
Question 21 Resource scarcity is a likely cause of conflict in organiz.docx
 
Question 2 Compare the eye to a camera by listing four of the basic co.docx
Question 2 Compare the eye to a camera by listing four of the basic co.docxQuestion 2 Compare the eye to a camera by listing four of the basic co.docx
Question 2 Compare the eye to a camera by listing four of the basic co.docx
 
Question 1- The alien species has decided that they will use a special.docx
Question 1- The alien species has decided that they will use a special.docxQuestion 1- The alien species has decided that they will use a special.docx
Question 1- The alien species has decided that they will use a special.docx
 
Question 13 Which of the following is the first stage of an experienti.docx
Question 13 Which of the following is the first stage of an experienti.docxQuestion 13 Which of the following is the first stage of an experienti.docx
Question 13 Which of the following is the first stage of an experienti.docx
 
Question 11 Active communication occurs by facial expressions- body po.docx
Question 11 Active communication occurs by facial expressions- body po.docxQuestion 11 Active communication occurs by facial expressions- body po.docx
Question 11 Active communication occurs by facial expressions- body po.docx
 
QUESTION 1 Interaction Design is designing interactive products to sup.docx
QUESTION 1 Interaction Design is designing interactive products to sup.docxQUESTION 1 Interaction Design is designing interactive products to sup.docx
QUESTION 1 Interaction Design is designing interactive products to sup.docx
 
question 1 What is the behavior of setting C locale- Strings are alway.docx
question 1 What is the behavior of setting C locale- Strings are alway.docxquestion 1 What is the behavior of setting C locale- Strings are alway.docx
question 1 What is the behavior of setting C locale- Strings are alway.docx
 

Recently uploaded

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
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
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
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
 
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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
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
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
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
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
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
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
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"
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
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
 
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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
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
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
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
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

Implement copy constructor, destructor, and assignment operator for linked list class

  • 1. Provide copy constructor, destructor, and assignment operator for the IntList class that stores a collection of integers using linked list. class ListNode { int value; ListNode * next; }; class IntList { public: ... IntList(const IntList & other); ~IntList(); IntList& operator =( const IntList & other ) ... private: int num; //the number of ints stored. ListNode * first; }; Solution Hi, I have implemented all functionality. Please test it in your test program using namespace std;
  • 2. class ListNode { public: int value; ListNode * next; }; class IntList { public: IntList(); IntList(const IntList & other); ~IntList(); void operator =( const IntList & other); private: int num; //the number of ints stored. ListNode * first; }; IntList::IntList(const IntList & other){ IntList *ptr = new IntList(); ListNode *temp = other.first; ListNode *temp1 = ptr->first; ListNode *firstLocal = NULL; while(temp != NULL){ if(firstLocal == NULL){ firstLocal = temp; temp1 = firstLocal; } else{ temp1->next = temp; temp1 = temp; } temp = temp->next; } ptr->first = firstLocal; ptr->num = other.num; } IntList::~IntList(){ while(first != NULL){ ListNode *local = first; first = first->next;
  • 3. delete local; } } IntList::IntList(){ first = NULL; num = 0; } void IntList::operator =( const IntList & other){ first = other.first; num = other.num; }