Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with my list 3 4 2 . h . It doesn't compile the expected output: class 1 : PradnyaDhala 8 AngieHam 7
I need help with my listh It doesn't compile the expected output: "class: PradnyaDhalaAngieHamCesarRuizPiqiTangiBillVollmannRussellWilson
ERROR::: Duplicate
Class: HankAaronCesarRuizPiqiTangiRussellWilsonJohnZorn
class and Merged:
HankAaronPradnyaDhalaAngieHamCesarRuizPiqiTangiBillVollmannRussellWilsonJohnZorn
Removed from class student AngieHam
class: HankAaronPradnyaDhalaBillVollmannRussellWilsonJohnZorn
soccer: MilesDavisCesarRuizRussellWilson
soccer class :
HankAaronMilesDavisPradnyaDhalaCesarRuizBillVollmannRussellWilsonJohnZorn
football: HankAaronMilesDavisPradnyaDhalaCesarRuizBillVollmannRussellWilsonJohnZorn
RussellWilson is on the football team
These are the numbers: here's my code: #ifndef LISTH
#define LISTH
#include
#include
#include
#include
#include "child.h
template
struct Node
T data;
Node next;
;
template
class List
public:
List;
Listconst List& source;
~List;
bool BuildListstd::string filename;
bool InsertT obj;
bool RemoveT target, T& result;
bool PeekT target, T& result const;
int Size const;
void DeleteList;
bool MergeList& list;
List& operatorconst List& source;
List operatorconst List& rhs const;
List& operatorconst List& rhs;
bool operatorconst List& rhs const;
bool operator!const List& rhs const;
template
friend std::ostream& operatorstd::ostream& os const List& list;
private:
Node head;
void CopyListconst List& source;
void RecursiveDeleteNode current;
void RecursiveMergeNode& dest, Node& source;
;
template
List::List : headnullptr
template
List::Listconst List& source : headnullptr
CopyListsource;
template
List::~List
DeleteList;
Member functions
template
bool List::BuildListstd::string filename
std::ifstream filefilename;
if file.isopen
return false; Failed to open file
T obj;
while file obj
Insertnew Tobj;
file.close;
return true;
template
bool List::InsertT obj
Node current head;
if obj
return false;
while current
if obj currentdata
return false; Duplicate item
current currentnext;
Node newNode new Node;
if newNode
return false; Memory allocation failed
newNodedata new Tobj; Copy the object
newNodenext nullptr;
current head;
Node prev nullptr;
while current && currentdata newNodedata
prev current;
current currentnext;
if prev
prevnext newNode;
else
head newNode;
newNodenext current;
return true;
template
bool List::RemoveT target, T& result
Node current head;
Node prev nullptr;
while current && currentdata target
prev current;
current currentnext;
if current
return false; Target not found
if prev
prevnext currentnext;
else
head currentnext;
result currentdata;
delete currentdata;
delete current;
return true;
template
bool List::PeekT target, T& result const
Node current head;
while current && currentdata target
current currentnext;
if current
return false; Target not found
result currentdata;
return true;
template
int List::Size const
int count ;
Node current head;
while current
count;
current currentnext;
return count;
template
void List::DeleteList
RecursiveDeletehead;
head nullptr;
template
bool List::MergeList& list
RecursiveMergehead listhead;
listDeleteList; Empty the merged list
return true;
Overloaded operators
template
List& List::operatorconst List& source
if this &source
DeleteList;
CopyListsource;
return this;
template
List List::operatorconst List& rhs const
List result this;
result rhs;
return result;
template
List& List::operatorconst List& rhs
Node current rhshead;
while current
T result;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started