SlideShare a Scribd company logo
1 of 4
Download to read offline
Main.cpp
#include <iostream>
#include "List.h"
int main() {
return 0;
}
List.h
#ifndef HW10_25_LIST_H
#define HW10_25_LIST_H
#include <string>
#include <vector>
using Item = std::string;
class List {
private:
class ListNode {
public:
Item item;
ListNode * next;
ListNode(Item i, ListNode *n=nullptr) {
item = i;
next = n;
}
};
ListNode * head = nullptr;
ListNode * tail = nullptr;
public:
class iterator {
ListNode *node;
iterator(ListNode *n) : node {n} {}
friend class List;
public:
Item& operator*() { return node->item; }
iterator& operator++() { node = node->next; return *this; }
bool operator!=(const iterator& other) const { return node != other.node; }
};
public:
List() = default;
List(const List& other);
List& operator=(const List& rhs);
List(List&& other);
List& operator=(List&& rhs);
~List();
bool empty() const { return head==nullptr; }
void push_back(const Item& a);
void push_front(const Item& a);
iterator begin() const { return iterator(head); }
iterator end() const { return iterator(nullptr); }
friend std::vector<void*> getListPtrs(const List&);
};
#endif //HW10_25_LIST_H
List.cpp
#include "List.h"
// IMPLEMENT MOVE CONSTRUCTOR
// IMPLEMENT MOVE ASSIGNMENT OPERATOR
List::List(const List& other) {
auto p = other.head;
while (p) {
push_back(p->item);
p = p->next;
}
}
List& List::operator=(const List& rhs) {
if (&rhs == this) return *this;
// delete old list
auto p = head;
while (p) {
auto tmp = p->next;
delete p;
p = tmp;
}
head = tail = nullptr;
// copy from rhs
p = rhs.head;
while (p) {
push_back(p->item);
}
// return reference to self
return *this;
}
List::~List() {
auto p = head;
while (p) {
auto tmp = p->next;
delete p;
p = tmp;
}
}
void List::push_back(const Item& a) {
auto node {new ListNode(a)};
if ( head == nullptr ) {
// empty list
head = node;
tail = node;
} else {
tail->next = node;
tail = node;
}
}
void List::push_front(const Item& a) {
auto node {new ListNode(a)};
if (head == nullptr) {
head = node;
tail = node;
}
else {
node->next = head;
head = node;
}
}
10.25 Move constructor and assignment for linked list Write a move constructor and a move
assignment operator for the List class.
Main-cpp  #include -iostream- #include -List-h- int main() {     retur.pdf

More Related Content

Similar to Main-cpp #include -iostream- #include -List-h- int main() { retur.pdf

This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfEricvtJFraserr
 
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
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfpoblettesedanoree498
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfanwarsadath111
 
For this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxFor this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxmckellarhastings
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfthangarajarivukadal
 
Turn the linked list implementation into a circular list Ha.pdf
Turn the linked list implementation into a circular list Ha.pdfTurn the linked list implementation into a circular list Ha.pdf
Turn the linked list implementation into a circular list Ha.pdfajayadinathcomputers
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03Nasir Mehmood
 
GIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docxGIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docxLeonardN9WWelchw
 
ItemNodeh include ltiostreamgt include ltstring.pdf
ItemNodeh    include ltiostreamgt include ltstring.pdfItemNodeh    include ltiostreamgt include ltstring.pdf
ItemNodeh include ltiostreamgt include ltstring.pdfacmefit
 
Lec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdfLec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdfKylaMaeGarcia1
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfcallawaycorb73779
 
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
 
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjhlinked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjhvasavim9
 
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
 
Provide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docxProvide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docxtodd921
 
C++ detyrat postim_slideshare
C++ detyrat postim_slideshareC++ detyrat postim_slideshare
C++ detyrat postim_slidesharetctal
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3ecomputernotes
 

Similar to Main-cpp #include -iostream- #include -List-h- int main() { retur.pdf (20)

This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.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
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
 
강의자료10
강의자료10강의자료10
강의자료10
 
For this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxFor this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docx
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdf
 
Turn the linked list implementation into a circular list Ha.pdf
Turn the linked list implementation into a circular list Ha.pdfTurn the linked list implementation into a circular list Ha.pdf
Turn the linked list implementation into a circular list Ha.pdf
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03
 
GIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docxGIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docx
 
ItemNodeh include ltiostreamgt include ltstring.pdf
ItemNodeh    include ltiostreamgt include ltstring.pdfItemNodeh    include ltiostreamgt include ltstring.pdf
ItemNodeh include ltiostreamgt include ltstring.pdf
 
Linked Stack program.docx
Linked Stack program.docxLinked Stack program.docx
Linked Stack program.docx
 
Lec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdfLec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdf
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.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
 
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjhlinked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
 
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
 
Provide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docxProvide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docx
 
C++ detyrat postim_slideshare
C++ detyrat postim_slideshareC++ detyrat postim_slideshare
C++ detyrat postim_slideshare
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3
 

More from PeterM9sWhitej

Elevation (m) Elevation.pdf
Elevation (m) Elevation.pdfElevation (m) Elevation.pdf
Elevation (m) Elevation.pdfPeterM9sWhitej
 
Electrical synapses utilize gap junction proteins to form channels bet.pdf
Electrical synapses utilize gap junction proteins to form channels bet.pdfElectrical synapses utilize gap junction proteins to form channels bet.pdf
Electrical synapses utilize gap junction proteins to form channels bet.pdfPeterM9sWhitej
 
Effective population size 1- FST Rate of migration 2- Ne Genetic dista.pdf
Effective population size 1- FST Rate of migration 2- Ne Genetic dista.pdfEffective population size 1- FST Rate of migration 2- Ne Genetic dista.pdf
Effective population size 1- FST Rate of migration 2- Ne Genetic dista.pdfPeterM9sWhitej
 
Effective teams need to have- A Clear Sense of Mission- Productive Int.pdf
Effective teams need to have- A Clear Sense of Mission- Productive Int.pdfEffective teams need to have- A Clear Sense of Mission- Productive Int.pdf
Effective teams need to have- A Clear Sense of Mission- Productive Int.pdfPeterM9sWhitej
 
Efecto de las transacciones en los flujos de efectivo Indique el efec.pdf
Efecto de las transacciones en los flujos de efectivo  Indique el efec.pdfEfecto de las transacciones en los flujos de efectivo  Indique el efec.pdf
Efecto de las transacciones en los flujos de efectivo Indique el efec.pdfPeterM9sWhitej
 
eEWove uses three procetses to manufactire ita for pesonar aiteruaft f.pdf
eEWove uses three procetses to manufactire ita for pesonar aiteruaft f.pdfeEWove uses three procetses to manufactire ita for pesonar aiteruaft f.pdf
eEWove uses three procetses to manufactire ita for pesonar aiteruaft f.pdfPeterM9sWhitej
 
Edit the script in to disable code which adds demonstration entries to.pdf
Edit the script in to disable code which adds demonstration entries to.pdfEdit the script in to disable code which adds demonstration entries to.pdf
Edit the script in to disable code which adds demonstration entries to.pdfPeterM9sWhitej
 
Eddie and other users of facebook and other social networking sites po.pdf
Eddie and other users of facebook and other social networking sites po.pdfEddie and other users of facebook and other social networking sites po.pdf
Eddie and other users of facebook and other social networking sites po.pdfPeterM9sWhitej
 
Ebusiness Communication Overview This activity provides an overview of.pdf
Ebusiness Communication Overview This activity provides an overview of.pdfEbusiness Communication Overview This activity provides an overview of.pdf
Ebusiness Communication Overview This activity provides an overview of.pdfPeterM9sWhitej
 
Ebbe went through an antibiotic course at the hospital- but then contr.pdf
Ebbe went through an antibiotic course at the hospital- but then contr.pdfEbbe went through an antibiotic course at the hospital- but then contr.pdf
Ebbe went through an antibiotic course at the hospital- but then contr.pdfPeterM9sWhitej
 
Earth-Sun Relationships - Solar Noon Angles Introduction- The purpose.pdf
Earth-Sun Relationships - Solar Noon Angles Introduction- The purpose.pdfEarth-Sun Relationships - Solar Noon Angles Introduction- The purpose.pdf
Earth-Sun Relationships - Solar Noon Angles Introduction- The purpose.pdfPeterM9sWhitej
 
Eamings per share are divided by and dividends per share are (Select.pdf
Eamings per share are divided by  and dividends per share are (Select.pdfEamings per share are divided by  and dividends per share are (Select.pdf
Eamings per share are divided by and dividends per share are (Select.pdfPeterM9sWhitej
 
Earth's mantle makes up of the total volume of the planet- 82-50- 54-6.pdf
Earth's mantle makes up of the total volume of the planet- 82-50- 54-6.pdfEarth's mantle makes up of the total volume of the planet- 82-50- 54-6.pdf
Earth's mantle makes up of the total volume of the planet- 82-50- 54-6.pdfPeterM9sWhitej
 
E- coli SALMONELLA LISTERA Major foods Gram Group Lowest D.pdf
E- coli SALMONELLA LISTERA Major foods       Gram Group       Lowest D.pdfE- coli SALMONELLA LISTERA Major foods       Gram Group       Lowest D.pdf
E- coli SALMONELLA LISTERA Major foods Gram Group Lowest D.pdfPeterM9sWhitej
 
Each tip (sp 1-4) represents a different species of ant- Imagine that.pdf
Each tip (sp 1-4) represents a different species of ant- Imagine that.pdfEach tip (sp 1-4) represents a different species of ant- Imagine that.pdf
Each tip (sp 1-4) represents a different species of ant- Imagine that.pdfPeterM9sWhitej
 
Each week you will submit a Media Journal entry- In the entry- you wil.pdf
Each week you will submit a Media Journal entry- In the entry- you wil.pdfEach week you will submit a Media Journal entry- In the entry- you wil.pdf
Each week you will submit a Media Journal entry- In the entry- you wil.pdfPeterM9sWhitej
 
E15-2 Fleishman Corporation issued 5-000 shares of its no-par common s.pdf
E15-2 Fleishman Corporation issued 5-000 shares of its no-par common s.pdfE15-2 Fleishman Corporation issued 5-000 shares of its no-par common s.pdf
E15-2 Fleishman Corporation issued 5-000 shares of its no-par common s.pdfPeterM9sWhitej
 
e Messages jGRASP Messages Run I-O Interactions Chapter24_2-java-31- w.pdf
e Messages jGRASP Messages Run I-O Interactions Chapter24_2-java-31- w.pdfe Messages jGRASP Messages Run I-O Interactions Chapter24_2-java-31- w.pdf
e Messages jGRASP Messages Run I-O Interactions Chapter24_2-java-31- w.pdfPeterM9sWhitej
 
Each of the following is an independent Case involving the ownership o.pdf
Each of the following is an independent Case involving the ownership o.pdfEach of the following is an independent Case involving the ownership o.pdf
Each of the following is an independent Case involving the ownership o.pdfPeterM9sWhitej
 
E1-12 Cepeda Corporation has the following cost records for June 2014-.pdf
E1-12 Cepeda Corporation has the following cost records for June 2014-.pdfE1-12 Cepeda Corporation has the following cost records for June 2014-.pdf
E1-12 Cepeda Corporation has the following cost records for June 2014-.pdfPeterM9sWhitej
 

More from PeterM9sWhitej (20)

Elevation (m) Elevation.pdf
Elevation (m) Elevation.pdfElevation (m) Elevation.pdf
Elevation (m) Elevation.pdf
 
Electrical synapses utilize gap junction proteins to form channels bet.pdf
Electrical synapses utilize gap junction proteins to form channels bet.pdfElectrical synapses utilize gap junction proteins to form channels bet.pdf
Electrical synapses utilize gap junction proteins to form channels bet.pdf
 
Effective population size 1- FST Rate of migration 2- Ne Genetic dista.pdf
Effective population size 1- FST Rate of migration 2- Ne Genetic dista.pdfEffective population size 1- FST Rate of migration 2- Ne Genetic dista.pdf
Effective population size 1- FST Rate of migration 2- Ne Genetic dista.pdf
 
Effective teams need to have- A Clear Sense of Mission- Productive Int.pdf
Effective teams need to have- A Clear Sense of Mission- Productive Int.pdfEffective teams need to have- A Clear Sense of Mission- Productive Int.pdf
Effective teams need to have- A Clear Sense of Mission- Productive Int.pdf
 
Efecto de las transacciones en los flujos de efectivo Indique el efec.pdf
Efecto de las transacciones en los flujos de efectivo  Indique el efec.pdfEfecto de las transacciones en los flujos de efectivo  Indique el efec.pdf
Efecto de las transacciones en los flujos de efectivo Indique el efec.pdf
 
eEWove uses three procetses to manufactire ita for pesonar aiteruaft f.pdf
eEWove uses three procetses to manufactire ita for pesonar aiteruaft f.pdfeEWove uses three procetses to manufactire ita for pesonar aiteruaft f.pdf
eEWove uses three procetses to manufactire ita for pesonar aiteruaft f.pdf
 
Edit the script in to disable code which adds demonstration entries to.pdf
Edit the script in to disable code which adds demonstration entries to.pdfEdit the script in to disable code which adds demonstration entries to.pdf
Edit the script in to disable code which adds demonstration entries to.pdf
 
Eddie and other users of facebook and other social networking sites po.pdf
Eddie and other users of facebook and other social networking sites po.pdfEddie and other users of facebook and other social networking sites po.pdf
Eddie and other users of facebook and other social networking sites po.pdf
 
Ebusiness Communication Overview This activity provides an overview of.pdf
Ebusiness Communication Overview This activity provides an overview of.pdfEbusiness Communication Overview This activity provides an overview of.pdf
Ebusiness Communication Overview This activity provides an overview of.pdf
 
Ebbe went through an antibiotic course at the hospital- but then contr.pdf
Ebbe went through an antibiotic course at the hospital- but then contr.pdfEbbe went through an antibiotic course at the hospital- but then contr.pdf
Ebbe went through an antibiotic course at the hospital- but then contr.pdf
 
Earth-Sun Relationships - Solar Noon Angles Introduction- The purpose.pdf
Earth-Sun Relationships - Solar Noon Angles Introduction- The purpose.pdfEarth-Sun Relationships - Solar Noon Angles Introduction- The purpose.pdf
Earth-Sun Relationships - Solar Noon Angles Introduction- The purpose.pdf
 
Eamings per share are divided by and dividends per share are (Select.pdf
Eamings per share are divided by  and dividends per share are (Select.pdfEamings per share are divided by  and dividends per share are (Select.pdf
Eamings per share are divided by and dividends per share are (Select.pdf
 
Earth's mantle makes up of the total volume of the planet- 82-50- 54-6.pdf
Earth's mantle makes up of the total volume of the planet- 82-50- 54-6.pdfEarth's mantle makes up of the total volume of the planet- 82-50- 54-6.pdf
Earth's mantle makes up of the total volume of the planet- 82-50- 54-6.pdf
 
E- coli SALMONELLA LISTERA Major foods Gram Group Lowest D.pdf
E- coli SALMONELLA LISTERA Major foods       Gram Group       Lowest D.pdfE- coli SALMONELLA LISTERA Major foods       Gram Group       Lowest D.pdf
E- coli SALMONELLA LISTERA Major foods Gram Group Lowest D.pdf
 
Each tip (sp 1-4) represents a different species of ant- Imagine that.pdf
Each tip (sp 1-4) represents a different species of ant- Imagine that.pdfEach tip (sp 1-4) represents a different species of ant- Imagine that.pdf
Each tip (sp 1-4) represents a different species of ant- Imagine that.pdf
 
Each week you will submit a Media Journal entry- In the entry- you wil.pdf
Each week you will submit a Media Journal entry- In the entry- you wil.pdfEach week you will submit a Media Journal entry- In the entry- you wil.pdf
Each week you will submit a Media Journal entry- In the entry- you wil.pdf
 
E15-2 Fleishman Corporation issued 5-000 shares of its no-par common s.pdf
E15-2 Fleishman Corporation issued 5-000 shares of its no-par common s.pdfE15-2 Fleishman Corporation issued 5-000 shares of its no-par common s.pdf
E15-2 Fleishman Corporation issued 5-000 shares of its no-par common s.pdf
 
e Messages jGRASP Messages Run I-O Interactions Chapter24_2-java-31- w.pdf
e Messages jGRASP Messages Run I-O Interactions Chapter24_2-java-31- w.pdfe Messages jGRASP Messages Run I-O Interactions Chapter24_2-java-31- w.pdf
e Messages jGRASP Messages Run I-O Interactions Chapter24_2-java-31- w.pdf
 
Each of the following is an independent Case involving the ownership o.pdf
Each of the following is an independent Case involving the ownership o.pdfEach of the following is an independent Case involving the ownership o.pdf
Each of the following is an independent Case involving the ownership o.pdf
 
E1-12 Cepeda Corporation has the following cost records for June 2014-.pdf
E1-12 Cepeda Corporation has the following cost records for June 2014-.pdfE1-12 Cepeda Corporation has the following cost records for June 2014-.pdf
E1-12 Cepeda Corporation has the following cost records for June 2014-.pdf
 

Recently uploaded

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
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
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 

Recently uploaded (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 

Main-cpp #include -iostream- #include -List-h- int main() { retur.pdf

  • 1. Main.cpp #include <iostream> #include "List.h" int main() { return 0; } List.h #ifndef HW10_25_LIST_H #define HW10_25_LIST_H #include <string> #include <vector> using Item = std::string; class List { private: class ListNode { public: Item item; ListNode * next; ListNode(Item i, ListNode *n=nullptr) { item = i; next = n; } }; ListNode * head = nullptr; ListNode * tail = nullptr; public: class iterator { ListNode *node; iterator(ListNode *n) : node {n} {} friend class List; public: Item& operator*() { return node->item; } iterator& operator++() { node = node->next; return *this; } bool operator!=(const iterator& other) const { return node != other.node; } };
  • 2. public: List() = default; List(const List& other); List& operator=(const List& rhs); List(List&& other); List& operator=(List&& rhs); ~List(); bool empty() const { return head==nullptr; } void push_back(const Item& a); void push_front(const Item& a); iterator begin() const { return iterator(head); } iterator end() const { return iterator(nullptr); } friend std::vector<void*> getListPtrs(const List&); }; #endif //HW10_25_LIST_H List.cpp #include "List.h" // IMPLEMENT MOVE CONSTRUCTOR // IMPLEMENT MOVE ASSIGNMENT OPERATOR List::List(const List& other) { auto p = other.head; while (p) { push_back(p->item); p = p->next; } } List& List::operator=(const List& rhs) { if (&rhs == this) return *this; // delete old list auto p = head; while (p) { auto tmp = p->next; delete p; p = tmp; } head = tail = nullptr;
  • 3. // copy from rhs p = rhs.head; while (p) { push_back(p->item); } // return reference to self return *this; } List::~List() { auto p = head; while (p) { auto tmp = p->next; delete p; p = tmp; } } void List::push_back(const Item& a) { auto node {new ListNode(a)}; if ( head == nullptr ) { // empty list head = node; tail = node; } else { tail->next = node; tail = node; } } void List::push_front(const Item& a) { auto node {new ListNode(a)}; if (head == nullptr) { head = node; tail = node; } else { node->next = head; head = node; } } 10.25 Move constructor and assignment for linked list Write a move constructor and a move assignment operator for the List class.