SlideShare a Scribd company logo
using namespace std;
template<typename T>
List<T>::List()
: m_head(new Element), m_end(m_head)
{
}
template<typename T>
List<T>::List(const List &list)
: m_head(new Element), m_end(m_head)
{
for (Element *p = list.m_head; p != list.m_end; p = p->next)
PutAtEnd(p->data);
}
template<typename T>
List<T>::~List()
{
BecomeEmpty();
delete m_end;
}
template<typename T>
List<T> & List<T>::operator=(List<T> rightSide)
{
swap(m_head, rightSide.m_head);
swap(m_end, rightSide.m_end);
return *this;
}
template<typename T>
bool List<T>::isEmpty() const
{
return (m_head == m_end);
}
template<typename T>
void List<T>::InsertAtBeginning(T data)
{
Element *neww = new Element;
neww->data = data;
neww->next = m_head;
m_head = neww;
}
template<typename T>
void List<T>::PutAtEnd(T data)
{
Element *newwEnd = new Element;
m_end->data = data;
m_end->next = newwEnd;
m_end = newwEnd;
}
template<typename T>
void List<T>::remove(typename List<T>::Iterator it)
{
if (it != this->begin())
throw "Unsupported operation";
Element * p = this->m_head;
this->m_head = this->m_head->next;
delete p;
}
template<typename T>
void List<T>::BecomeEmpty()
{
while (!isEmpty())
{
Element *p = m_head;
m_head = m_head->next;
delete p;
}
}
template<typename T>
typename List<T>::Iterator List<T>::begin()
{
Iterator iter;
iter.m_Element = m_head;
return iter;
}
template<typename T>
typename List<T>::Iterator List<T>::end()
{
Iterator iter;
iter.m_Element = m_end;
return iter;
}
template<typename T>
typename List<T>::ConstantIterator List<T>::begin() const
{
ConstantIterator iter;
iter.m_Element = m_head;
return iter;
}
template<typename T>
typename List<T>::ConstantIterator List<T>::end() const
{
ConstantIterator iter;
iter.m_Element = m_end;
return iter;
}
// Class Iterator
template<typename T>
typename List<T>::Iterator & List<T>::Iterator::operator++()
{
m_Element = m_Element->next;
return *this;
}
template<typename T>
const typename List<T>::Iterator List<T>::Iterator::operator++(int)
{
Iterator iter(*this);
++(*this);
return iter;
}
// Class ConstantIterator
template<typename T>
typename List<T>::ConstantIterator & List<T>::ConstantIterator::operator++()
{
m_Element = m_Element->next;
return *this;
}
template<typename T>
const typename List<T>::ConstantIterator
List<T>::ConstantIterator::operator++(int)
{
ConstantIterator iter(*this);
++(*this);
return iter;
}
template<typename T>
std::ostream &operator<<(std::ostream &steam, const List<T> &list)
{
for (typename List<T>::ConstantIterator iter = list.begin(); iter !=
list.end(); ++iter)
steam << *iter << " ";
return steam;
}

More Related Content

What's hot

Linked list
Linked listLinked list
Linked list
Ajharul Abedeen
 
Data Structure (Circular Linked List)
Data Structure (Circular Linked List)Data Structure (Circular Linked List)
Data Structure (Circular Linked List)
Adam Mukharil Bachtiar
 
Linked list
Linked list Linked list
Linked list
Arbind Mandal
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
Durga Devi
 
The Ring programming language version 1.5.4 book - Part 22 of 185
The Ring programming language version 1.5.4 book - Part 22 of 185The Ring programming language version 1.5.4 book - Part 22 of 185
The Ring programming language version 1.5.4 book - Part 22 of 185
Mahmoud Samir Fayed
 
Single linked list
Single linked listSingle linked list
Single linked list
jasbirsingh chauhan
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196
Mahmoud Samir Fayed
 
Linked lists
Linked listsLinked lists
Linked list
Linked listLinked list
Linked list
akshat360
 
The Ring programming language version 1.3 book - Part 14 of 88
The Ring programming language version 1.3 book - Part 14 of 88The Ring programming language version 1.3 book - Part 14 of 88
The Ring programming language version 1.3 book - Part 14 of 88
Mahmoud Samir Fayed
 
Presentation topic is stick data structure
Presentation topic is stick data structurePresentation topic is stick data structure
Presentation topic is stick data structure
AizazAli21
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked list
Vivek Bhargav
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
nitamhaske
 
Arrays
ArraysArrays
Arrays
afzal pa
 
Linked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory AllocationLinked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory Allocation
Prof Ansari
 
The Ring programming language version 1.9 book - Part 29 of 210
The Ring programming language version 1.9 book - Part 29 of 210The Ring programming language version 1.9 book - Part 29 of 210
The Ring programming language version 1.9 book - Part 29 of 210
Mahmoud Samir Fayed
 
6. binary tree
6. binary tree6. binary tree
6. binary tree
Geunhyung Kim
 

What's hot (20)

Linked list
Linked listLinked list
Linked list
 
Data Structure (Circular Linked List)
Data Structure (Circular Linked List)Data Structure (Circular Linked List)
Data Structure (Circular Linked List)
 
Linked list
Linked list Linked list
Linked list
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
 
The Ring programming language version 1.5.4 book - Part 22 of 185
The Ring programming language version 1.5.4 book - Part 22 of 185The Ring programming language version 1.5.4 book - Part 22 of 185
The Ring programming language version 1.5.4 book - Part 22 of 185
 
Linked list
Linked listLinked list
Linked list
 
Single linked list
Single linked listSingle linked list
Single linked list
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196
 
Linked lists
Linked listsLinked lists
Linked lists
 
Linked list
Linked listLinked list
Linked list
 
The Ring programming language version 1.3 book - Part 14 of 88
The Ring programming language version 1.3 book - Part 14 of 88The Ring programming language version 1.3 book - Part 14 of 88
The Ring programming language version 1.3 book - Part 14 of 88
 
Sample sql
Sample sqlSample sql
Sample sql
 
Presentation topic is stick data structure
Presentation topic is stick data structurePresentation topic is stick data structure
Presentation topic is stick data structure
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked list
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Arrays
ArraysArrays
Arrays
 
Linked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory AllocationLinked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory Allocation
 
The Ring programming language version 1.9 book - Part 29 of 210
The Ring programming language version 1.9 book - Part 29 of 210The Ring programming language version 1.9 book - Part 29 of 210
The Ring programming language version 1.9 book - Part 29 of 210
 
Algo>ADT list & linked list
Algo>ADT list & linked listAlgo>ADT list & linked list
Algo>ADT list & linked list
 
6. binary tree
6. binary tree6. binary tree
6. binary tree
 

Viewers also liked

Tehnika i mladi
Tehnika i mladiTehnika i mladi
Tehnika i mladi
Idon't Reallydogs
 
Dorota prezentacja
Dorota prezentacjaDorota prezentacja
Dorota prezentacjarafko124
 
كتاب الأقصى.. عرض المسلمين
كتاب الأقصى.. عرض المسلمينكتاب الأقصى.. عرض المسلمين
كتاب الأقصى.. عرض المسلمينalbasuninet
 
Früchte
FrüchteFrüchte
Früchte
rafko124
 
Spy Software
Spy SoftwareSpy Software
Spy Software
spyindia01
 
TBertani Resume 21 Apr 2015
TBertani Resume 21 Apr 2015TBertani Resume 21 Apr 2015
TBertani Resume 21 Apr 2015Teresa Bertani
 
Sporty
SportySporty
Sporty
rafko124
 
Job discription kua
Job discription kuaJob discription kua
Job discription kua
Yoyon Asfai
 
Elektrootporno zavarivanje
Elektrootporno zavarivanjeElektrootporno zavarivanje
Elektrootporno zavarivanje
Idon't Reallydogs
 
Contoh Undngan
Contoh Undngan Contoh Undngan
Contoh Undngan
Yoyon Asfai
 

Viewers also liked (14)

Tehnika i mladi
Tehnika i mladiTehnika i mladi
Tehnika i mladi
 
Rana brijrajsinh (1)
Rana brijrajsinh (1)Rana brijrajsinh (1)
Rana brijrajsinh (1)
 
Dorota prezentacja
Dorota prezentacjaDorota prezentacja
Dorota prezentacja
 
cv[1]
cv[1]cv[1]
cv[1]
 
كتاب الأقصى.. عرض المسلمين
كتاب الأقصى.. عرض المسلمينكتاب الأقصى.. عرض المسلمين
كتاب الأقصى.. عرض المسلمين
 
Rana brijrajsinh
Rana brijrajsinhRana brijrajsinh
Rana brijrajsinh
 
Früchte
FrüchteFrüchte
Früchte
 
Spy Software
Spy SoftwareSpy Software
Spy Software
 
TBertani Resume 21 Apr 2015
TBertani Resume 21 Apr 2015TBertani Resume 21 Apr 2015
TBertani Resume 21 Apr 2015
 
cv[1]
cv[1]cv[1]
cv[1]
 
Sporty
SportySporty
Sporty
 
Job discription kua
Job discription kuaJob discription kua
Job discription kua
 
Elektrootporno zavarivanje
Elektrootporno zavarivanjeElektrootporno zavarivanje
Elektrootporno zavarivanje
 
Contoh Undngan
Contoh Undngan Contoh Undngan
Contoh Undngan
 

Similar to My problem

dynamicList.ppt
dynamicList.pptdynamicList.ppt
dynamicList.ppt
ssuser0be977
 
Please solve the TODO parts include LinkedListcpph tem.pdf
Please solve the TODO parts  include LinkedListcpph tem.pdfPlease solve the TODO parts  include LinkedListcpph tem.pdf
Please solve the TODO parts include LinkedListcpph tem.pdf
aggarwalopticalsco
 
Implement a function TNode copy_tree(TNode t) that creates a copy .pdf
Implement a function TNode copy_tree(TNode t) that creates a copy .pdfImplement a function TNode copy_tree(TNode t) that creates a copy .pdf
Implement a function TNode copy_tree(TNode t) that creates a copy .pdf
feetshoemart
 
Please code in C++ and do only the �TO DO�s and all of them. There a.pdf
Please code in C++ and do only the �TO DO�s and all of them. There a.pdfPlease code in C++ and do only the �TO DO�s and all of them. There a.pdf
Please code in C++ and do only the �TO DO�s and all of them. There a.pdf
farankureshi
 
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
DIPESH30
 
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
LeonardN9WWelchw
 
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
eyewaregallery
 
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdf
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdfPlease complete ALL of the �TO DO�s in this code. I am really strugg.pdf
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdf
support58
 
#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docx#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docx
ajoy21
 
C++ extension methods
C++ extension methodsC++ extension methods
C++ extension methods
phil_nash
 
C++ detyrat postim_slideshare
C++ detyrat postim_slideshareC++ detyrat postim_slideshare
C++ detyrat postim_slideshare
tctal
 
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdfC++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
feelinggift
 
4) 15 points- Linked Lists- Consider the linked list template-type.docx
4) 15 points-  Linked Lists-   Consider the linked list  template-type.docx4) 15 points-  Linked Lists-   Consider the linked list  template-type.docx
4) 15 points- Linked Lists- Consider the linked list template-type.docx
KevinrDQBowerq
 
Assume a list has the following element- write a function to interch.docx
Assume a list has the following element-   write a function to interch.docxAssume a list has the following element-   write a function to interch.docx
Assume a list has the following element- write a function to interch.docx
olsenlinnea427
 
public class SLLT { protected SLLNodeT head, tail; pub.pdf
public class SLLT {     protected SLLNodeT head, tail;     pub.pdfpublic class SLLT {     protected SLLNodeT head, tail;     pub.pdf
public class SLLT { protected SLLNodeT head, tail; pub.pdf
clarityvision
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.pdf
AravindAnand21
 

Similar to My problem (20)

dynamicList.ppt
dynamicList.pptdynamicList.ppt
dynamicList.ppt
 
Please solve the TODO parts include LinkedListcpph tem.pdf
Please solve the TODO parts  include LinkedListcpph tem.pdfPlease solve the TODO parts  include LinkedListcpph tem.pdf
Please solve the TODO parts include LinkedListcpph tem.pdf
 
Tugas1
Tugas1Tugas1
Tugas1
 
Implement a function TNode copy_tree(TNode t) that creates a copy .pdf
Implement a function TNode copy_tree(TNode t) that creates a copy .pdfImplement a function TNode copy_tree(TNode t) that creates a copy .pdf
Implement a function TNode copy_tree(TNode t) that creates a copy .pdf
 
Please code in C++ and do only the �TO DO�s and all of them. There a.pdf
Please code in C++ and do only the �TO DO�s and all of them. There a.pdfPlease code in C++ and do only the �TO DO�s and all of them. There a.pdf
Please code in C++ and do only the �TO DO�s and all of them. There a.pdf
 
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
 
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
 
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
 
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdf
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdfPlease complete ALL of the �TO DO�s in this code. I am really strugg.pdf
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdf
 
#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docx#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docx
 
Linked list1
Linked list1Linked list1
Linked list1
 
C++ extension methods
C++ extension methodsC++ extension methods
C++ extension methods
 
C++ detyrat postim_slideshare
C++ detyrat postim_slideshareC++ detyrat postim_slideshare
C++ detyrat postim_slideshare
 
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdfC++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
 
Chapter14
Chapter14Chapter14
Chapter14
 
강의자료10
강의자료10강의자료10
강의자료10
 
4) 15 points- Linked Lists- Consider the linked list template-type.docx
4) 15 points-  Linked Lists-   Consider the linked list  template-type.docx4) 15 points-  Linked Lists-   Consider the linked list  template-type.docx
4) 15 points- Linked Lists- Consider the linked list template-type.docx
 
Assume a list has the following element- write a function to interch.docx
Assume a list has the following element-   write a function to interch.docxAssume a list has the following element-   write a function to interch.docx
Assume a list has the following element- write a function to interch.docx
 
public class SLLT { protected SLLNodeT head, tail; pub.pdf
public class SLLT {     protected SLLNodeT head, tail;     pub.pdfpublic class SLLT {     protected SLLNodeT head, tail;     pub.pdf
public class SLLT { protected SLLNodeT head, tail; pub.pdf
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.pdf
 

Recently uploaded

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 

My problem

  • 1. using namespace std; template<typename T> List<T>::List() : m_head(new Element), m_end(m_head) { } template<typename T> List<T>::List(const List &list) : m_head(new Element), m_end(m_head) { for (Element *p = list.m_head; p != list.m_end; p = p->next) PutAtEnd(p->data); } template<typename T> List<T>::~List() { BecomeEmpty(); delete m_end; } template<typename T> List<T> & List<T>::operator=(List<T> rightSide) { swap(m_head, rightSide.m_head); swap(m_end, rightSide.m_end); return *this; } template<typename T> bool List<T>::isEmpty() const { return (m_head == m_end); } template<typename T> void List<T>::InsertAtBeginning(T data) { Element *neww = new Element; neww->data = data; neww->next = m_head; m_head = neww; } template<typename T> void List<T>::PutAtEnd(T data) { Element *newwEnd = new Element; m_end->data = data; m_end->next = newwEnd; m_end = newwEnd; } template<typename T> void List<T>::remove(typename List<T>::Iterator it) { if (it != this->begin()) throw "Unsupported operation";
  • 2. Element * p = this->m_head; this->m_head = this->m_head->next; delete p; } template<typename T> void List<T>::BecomeEmpty() { while (!isEmpty()) { Element *p = m_head; m_head = m_head->next; delete p; } } template<typename T> typename List<T>::Iterator List<T>::begin() { Iterator iter; iter.m_Element = m_head; return iter; } template<typename T> typename List<T>::Iterator List<T>::end() { Iterator iter; iter.m_Element = m_end; return iter; } template<typename T> typename List<T>::ConstantIterator List<T>::begin() const { ConstantIterator iter; iter.m_Element = m_head; return iter; } template<typename T> typename List<T>::ConstantIterator List<T>::end() const { ConstantIterator iter; iter.m_Element = m_end; return iter; } // Class Iterator template<typename T> typename List<T>::Iterator & List<T>::Iterator::operator++() { m_Element = m_Element->next; return *this; } template<typename T> const typename List<T>::Iterator List<T>::Iterator::operator++(int) {
  • 3. Iterator iter(*this); ++(*this); return iter; } // Class ConstantIterator template<typename T> typename List<T>::ConstantIterator & List<T>::ConstantIterator::operator++() { m_Element = m_Element->next; return *this; } template<typename T> const typename List<T>::ConstantIterator List<T>::ConstantIterator::operator++(int) { ConstantIterator iter(*this); ++(*this); return iter; } template<typename T> std::ostream &operator<<(std::ostream &steam, const List<T> &list) { for (typename List<T>::ConstantIterator iter = list.begin(); iter != list.end(); ++iter) steam << *iter << " "; return steam; }