SlideShare a Scribd company logo
(main.cpp)
#include "ListItem.h"
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main () {
// working with a vector of ints
int myints[] = { 5, 10, 15, 20 };
std::vector<int> vectorOfNums (myints,myints+4);
std::vector<int>::iterator vectItr;
// TODO: write call to find() to search for 15 in the vectorOfNums
if (vectItr != vectorOfNums.end())
std::cout << "Element found: " << *vectItr << 'n';
else
std::cout << "Element not foundn";
// TODO: write call to find() to search for 85 in the vectorOfNums
if (vectItr != vectorOfNums.end())
std::cout << "Element found: " << *vectItr << 'n';
else
std::cout << "Element not foundn";
// working with a list of strings
std::list<std::string> listOfWords;
std::list<std::string>::iterator listIter;
listOfWords.push_back("house");
listOfWords.push_back("cup");
listOfWords.push_back("car");
listOfWords.push_back("lamp");
// TODO: write call to find() to search for 'lamp' in the listOfWords and write
// the code to test for it
// TODO: write call to find() to search for 'music' in the listOfWords and write
// the code to test for it
// working with a list of listItems
std::list<ListItem> listOfItems;
std::list<ListItem>::iterator listItemIter;
listOfItems.push_back(ListItem("shoes", 150.95));
listOfItems.push_back(ListItem("laptop", 1245.85));
listOfItems.push_back(ListItem("dress", 85.68));
listOfItems.push_back(ListItem("polo shirt", 25.67));
// TODO: write call to find() to search for the 'dress' object in the listOfItems and write
// the code to test for it
// TODO: write call to find() to search for the 'slacks' object that cost '85.68' in the listOfItems and
write
// the code to test for it
return 0;
}
(ListItem.h)
#ifndef LISTITEMH
#define LISTITEMH
#include <string>
using namespace std;
class ListItem {
public:
ListItem();
ListItem(string itemInit, double priceInit);
// Print this node
void PrintNodeData();
// TODO: write the prototype for the '==' overload
// TODO: write the prototype for '<<' overload (hint: must be a friend)
private:
string item;
double price;
};
#endif
(ListIem.cpp)
#include "ListItem.h"
#include <iostream>
ListItem::ListItem() {
item = "";
price = 0.0;
}
ListItem::ListItem(string itemInit, double priceInit) {
item = itemInit;
price = priceInit;
}
// Print this node
void ListItem::PrintNodeData() {
cout << item << ": $" << price << endl;
}
// TODO: write the definition for the '==' overload
// TODO: write the prototype for '<<' overload
Given a Listitem class, complete main() using algorithms from the STL (STL Algorithms). An
example algorithm the find(): find (Inputiterator first, Inputiterator last, const T& val) The find uses
two iterators for the bounds of the search, first and last. The 3rd parameter is the value being
searched for. if we look inside the find() we might see code like this (ref cplusplus.com): The
description of find () states "The function uses operator== to compare the individual elements to
val". This means that any object we want to search for needs to be have the capability of
performing ==. And this may mean implementing the overload if the data type of the object does
not already have this overload. Note that C++ types like int, float, double, and string already
support this. Your task is to follow the prompts in main() and write the code required. For some of
the tests, you will need to provide support for overloaded operators in the Listltem class.
419632.1188960.q3zqy7

More Related Content

Similar to maincpp include ListItemh include ltstringgt in.pdf

Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Meghaj Mallick
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
Han Lee
 
Implementation File- -------------------------------------------------.docx
Implementation File- -------------------------------------------------.docxImplementation File- -------------------------------------------------.docx
Implementation File- -------------------------------------------------.docx
RyanEAcTuckern
 
Need help with the TODO's (DONE IN C++) #pragma once #include -funct.pdf
Need help with the TODO's (DONE IN C++) #pragma once   #include -funct.pdfNeed help with the TODO's (DONE IN C++) #pragma once   #include -funct.pdf
Need help with the TODO's (DONE IN C++) #pragma once #include -funct.pdf
actexerode
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
vishalateen
 
Lecture11 standard template-library
Lecture11 standard template-libraryLecture11 standard template-library
Lecture11 standard template-libraryHariz Mustafa
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
HIMANSUKUMAR12
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
aathmaproducts
 
You are required to implement the following functions for doubly linke.docx
You are required to implement the following functions for doubly linke.docxYou are required to implement the following functions for doubly linke.docx
You are required to implement the following functions for doubly linke.docx
Jonathan5GxRossk
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
aathiauto
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptx
JumanneChiyanda
 
Given an array nums of size n- return the majority element- The majori.pdf
Given an array nums of size n- return the majority element- The majori.pdfGiven an array nums of size n- return the majority element- The majori.pdf
Given an array nums of size n- return the majority element- The majori.pdf
MattCu9Parrd
 
C++ Secure Programming
C++ Secure ProgrammingC++ Secure Programming
C++ Secure Programming
Marian Marinov
 
C++11 - STL Additions
C++11 - STL AdditionsC++11 - STL Additions
C++11 - STL Additions
GlobalLogic Ukraine
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
Icaii Infotech
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
fortmdu
 
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
feelinggift
 
Write the C++ code for a function getInput which will read in an unkno.docx
Write the C++ code for a function getInput which will read in an unkno.docxWrite the C++ code for a function getInput which will read in an unkno.docx
Write the C++ code for a function getInput which will read in an unkno.docx
karlynwih
 

Similar to maincpp include ListItemh include ltstringgt in.pdf (20)

Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
 
Implementation File- -------------------------------------------------.docx
Implementation File- -------------------------------------------------.docxImplementation File- -------------------------------------------------.docx
Implementation File- -------------------------------------------------.docx
 
Need help with the TODO's (DONE IN C++) #pragma once #include -funct.pdf
Need help with the TODO's (DONE IN C++) #pragma once   #include -funct.pdfNeed help with the TODO's (DONE IN C++) #pragma once   #include -funct.pdf
Need help with the TODO's (DONE IN C++) #pragma once #include -funct.pdf
 
PathOfMostResistance
PathOfMostResistancePathOfMostResistance
PathOfMostResistance
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
 
Lecture11 standard template-library
Lecture11 standard template-libraryLecture11 standard template-library
Lecture11 standard template-library
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
 
You are required to implement the following functions for doubly linke.docx
You are required to implement the following functions for doubly linke.docxYou are required to implement the following functions for doubly linke.docx
You are required to implement the following functions for doubly linke.docx
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptx
 
Given an array nums of size n- return the majority element- The majori.pdf
Given an array nums of size n- return the majority element- The majori.pdfGiven an array nums of size n- return the majority element- The majori.pdf
Given an array nums of size n- return the majority element- The majori.pdf
 
C++ Secure Programming
C++ Secure ProgrammingC++ Secure Programming
C++ Secure Programming
 
C++11 - STL Additions
C++11 - STL AdditionsC++11 - STL Additions
C++11 - STL Additions
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.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
 
강의자료10
강의자료10강의자료10
강의자료10
 
Write the C++ code for a function getInput which will read in an unkno.docx
Write the C++ code for a function getInput which will read in an unkno.docxWrite the C++ code for a function getInput which will read in an unkno.docx
Write the C++ code for a function getInput which will read in an unkno.docx
 

More from abiwarmaa

Data Matrix is Such data set can be represented by a n by.pdf
Data Matrix is  Such data set can be represented by a n by.pdfData Matrix is  Such data set can be represented by a n by.pdf
Data Matrix is Such data set can be represented by a n by.pdf
abiwarmaa
 
Desarrolle un modelo de lienzo de modelo de negocio con det.pdf
Desarrolle un modelo de lienzo de modelo de negocio con det.pdfDesarrolle un modelo de lienzo de modelo de negocio con det.pdf
Desarrolle un modelo de lienzo de modelo de negocio con det.pdf
abiwarmaa
 
Bir hizmet irketi olan Easy Ltd bilano gn dzenlemeleri.pdf
Bir hizmet irketi olan Easy Ltd bilano gn dzenlemeleri.pdfBir hizmet irketi olan Easy Ltd bilano gn dzenlemeleri.pdf
Bir hizmet irketi olan Easy Ltd bilano gn dzenlemeleri.pdf
abiwarmaa
 
Assuming that the user inputs 1524 what does the following .pdf
Assuming that the user inputs 1524 what does the following .pdfAssuming that the user inputs 1524 what does the following .pdf
Assuming that the user inputs 1524 what does the following .pdf
abiwarmaa
 
1Which of the following best describes bryozoans aQuestion.pdf
1Which of the following best describes bryozoans aQuestion.pdf1Which of the following best describes bryozoans aQuestion.pdf
1Which of the following best describes bryozoans aQuestion.pdf
abiwarmaa
 
63 64 Data tablebalance sheet as of June 30 201X ente.pdf
63 64 Data tablebalance sheet as of June 30 201X ente.pdf63 64 Data tablebalance sheet as of June 30 201X ente.pdf
63 64 Data tablebalance sheet as of June 30 201X ente.pdf
abiwarmaa
 
PROBLEM 3 At yearend Myra Company reported cash and cash e.pdf
PROBLEM 3 At yearend Myra Company reported cash and cash e.pdfPROBLEM 3 At yearend Myra Company reported cash and cash e.pdf
PROBLEM 3 At yearend Myra Company reported cash and cash e.pdf
abiwarmaa
 
You are required to use Verilog structural modeling to desig.pdf
You are required to use Verilog structural modeling to desig.pdfYou are required to use Verilog structural modeling to desig.pdf
You are required to use Verilog structural modeling to desig.pdf
abiwarmaa
 
Which of the following statements regarding DUNS is not true.pdf
Which of the following statements regarding DUNS is not true.pdfWhich of the following statements regarding DUNS is not true.pdf
Which of the following statements regarding DUNS is not true.pdf
abiwarmaa
 
What should Jamal propose as a strategy for BlackBerry as a .pdf
What should Jamal propose as a strategy for BlackBerry as a .pdfWhat should Jamal propose as a strategy for BlackBerry as a .pdf
What should Jamal propose as a strategy for BlackBerry as a .pdf
abiwarmaa
 
What is the difference between the SW and OT areas of a SWOT.pdf
What is the difference between the SW and OT areas of a SWOT.pdfWhat is the difference between the SW and OT areas of a SWOT.pdf
What is the difference between the SW and OT areas of a SWOT.pdf
abiwarmaa
 
Use maple 13 to write the code 5 Consider the polar curve r.pdf
Use maple 13 to write the code 5 Consider the polar curve r.pdfUse maple 13 to write the code 5 Consider the polar curve r.pdf
Use maple 13 to write the code 5 Consider the polar curve r.pdf
abiwarmaa
 
The table shown below gives information on a variable for fo.pdf
The table shown below gives information on a variable for fo.pdfThe table shown below gives information on a variable for fo.pdf
The table shown below gives information on a variable for fo.pdf
abiwarmaa
 
Suppose X and Y are independent Paretodistributed with cu.pdf
Suppose X and Y are independent Paretodistributed with cu.pdfSuppose X and Y are independent Paretodistributed with cu.pdf
Suppose X and Y are independent Paretodistributed with cu.pdf
abiwarmaa
 
Real Value Corporation the Company is a public company .pdf
Real Value Corporation the Company is a public company .pdfReal Value Corporation the Company is a public company .pdf
Real Value Corporation the Company is a public company .pdf
abiwarmaa
 
pass but that all but the most sophisticated computer progra.pdf
pass but that all but the most sophisticated computer progra.pdfpass but that all but the most sophisticated computer progra.pdf
pass but that all but the most sophisticated computer progra.pdf
abiwarmaa
 
Nur Inc is a private company that designs manufactures a.pdf
Nur Inc is a private company that designs manufactures a.pdfNur Inc is a private company that designs manufactures a.pdf
Nur Inc is a private company that designs manufactures a.pdf
abiwarmaa
 
MedTex una gran empresa farmacutica con sede en Texas qu.pdf
MedTex una gran empresa farmacutica con sede en Texas qu.pdfMedTex una gran empresa farmacutica con sede en Texas qu.pdf
MedTex una gran empresa farmacutica con sede en Texas qu.pdf
abiwarmaa
 
JS es un hombre de 42 aos que vive en el Medio Oeste y es m.pdf
JS es un hombre de 42 aos que vive en el Medio Oeste y es m.pdfJS es un hombre de 42 aos que vive en el Medio Oeste y es m.pdf
JS es un hombre de 42 aos que vive en el Medio Oeste y es m.pdf
abiwarmaa
 
If we had classified health worker as rich if they earned .pdf
If we had classified health worker as rich if they earned .pdfIf we had classified health worker as rich if they earned .pdf
If we had classified health worker as rich if they earned .pdf
abiwarmaa
 

More from abiwarmaa (20)

Data Matrix is Such data set can be represented by a n by.pdf
Data Matrix is  Such data set can be represented by a n by.pdfData Matrix is  Such data set can be represented by a n by.pdf
Data Matrix is Such data set can be represented by a n by.pdf
 
Desarrolle un modelo de lienzo de modelo de negocio con det.pdf
Desarrolle un modelo de lienzo de modelo de negocio con det.pdfDesarrolle un modelo de lienzo de modelo de negocio con det.pdf
Desarrolle un modelo de lienzo de modelo de negocio con det.pdf
 
Bir hizmet irketi olan Easy Ltd bilano gn dzenlemeleri.pdf
Bir hizmet irketi olan Easy Ltd bilano gn dzenlemeleri.pdfBir hizmet irketi olan Easy Ltd bilano gn dzenlemeleri.pdf
Bir hizmet irketi olan Easy Ltd bilano gn dzenlemeleri.pdf
 
Assuming that the user inputs 1524 what does the following .pdf
Assuming that the user inputs 1524 what does the following .pdfAssuming that the user inputs 1524 what does the following .pdf
Assuming that the user inputs 1524 what does the following .pdf
 
1Which of the following best describes bryozoans aQuestion.pdf
1Which of the following best describes bryozoans aQuestion.pdf1Which of the following best describes bryozoans aQuestion.pdf
1Which of the following best describes bryozoans aQuestion.pdf
 
63 64 Data tablebalance sheet as of June 30 201X ente.pdf
63 64 Data tablebalance sheet as of June 30 201X ente.pdf63 64 Data tablebalance sheet as of June 30 201X ente.pdf
63 64 Data tablebalance sheet as of June 30 201X ente.pdf
 
PROBLEM 3 At yearend Myra Company reported cash and cash e.pdf
PROBLEM 3 At yearend Myra Company reported cash and cash e.pdfPROBLEM 3 At yearend Myra Company reported cash and cash e.pdf
PROBLEM 3 At yearend Myra Company reported cash and cash e.pdf
 
You are required to use Verilog structural modeling to desig.pdf
You are required to use Verilog structural modeling to desig.pdfYou are required to use Verilog structural modeling to desig.pdf
You are required to use Verilog structural modeling to desig.pdf
 
Which of the following statements regarding DUNS is not true.pdf
Which of the following statements regarding DUNS is not true.pdfWhich of the following statements regarding DUNS is not true.pdf
Which of the following statements regarding DUNS is not true.pdf
 
What should Jamal propose as a strategy for BlackBerry as a .pdf
What should Jamal propose as a strategy for BlackBerry as a .pdfWhat should Jamal propose as a strategy for BlackBerry as a .pdf
What should Jamal propose as a strategy for BlackBerry as a .pdf
 
What is the difference between the SW and OT areas of a SWOT.pdf
What is the difference between the SW and OT areas of a SWOT.pdfWhat is the difference between the SW and OT areas of a SWOT.pdf
What is the difference between the SW and OT areas of a SWOT.pdf
 
Use maple 13 to write the code 5 Consider the polar curve r.pdf
Use maple 13 to write the code 5 Consider the polar curve r.pdfUse maple 13 to write the code 5 Consider the polar curve r.pdf
Use maple 13 to write the code 5 Consider the polar curve r.pdf
 
The table shown below gives information on a variable for fo.pdf
The table shown below gives information on a variable for fo.pdfThe table shown below gives information on a variable for fo.pdf
The table shown below gives information on a variable for fo.pdf
 
Suppose X and Y are independent Paretodistributed with cu.pdf
Suppose X and Y are independent Paretodistributed with cu.pdfSuppose X and Y are independent Paretodistributed with cu.pdf
Suppose X and Y are independent Paretodistributed with cu.pdf
 
Real Value Corporation the Company is a public company .pdf
Real Value Corporation the Company is a public company .pdfReal Value Corporation the Company is a public company .pdf
Real Value Corporation the Company is a public company .pdf
 
pass but that all but the most sophisticated computer progra.pdf
pass but that all but the most sophisticated computer progra.pdfpass but that all but the most sophisticated computer progra.pdf
pass but that all but the most sophisticated computer progra.pdf
 
Nur Inc is a private company that designs manufactures a.pdf
Nur Inc is a private company that designs manufactures a.pdfNur Inc is a private company that designs manufactures a.pdf
Nur Inc is a private company that designs manufactures a.pdf
 
MedTex una gran empresa farmacutica con sede en Texas qu.pdf
MedTex una gran empresa farmacutica con sede en Texas qu.pdfMedTex una gran empresa farmacutica con sede en Texas qu.pdf
MedTex una gran empresa farmacutica con sede en Texas qu.pdf
 
JS es un hombre de 42 aos que vive en el Medio Oeste y es m.pdf
JS es un hombre de 42 aos que vive en el Medio Oeste y es m.pdfJS es un hombre de 42 aos que vive en el Medio Oeste y es m.pdf
JS es un hombre de 42 aos que vive en el Medio Oeste y es m.pdf
 
If we had classified health worker as rich if they earned .pdf
If we had classified health worker as rich if they earned .pdfIf we had classified health worker as rich if they earned .pdf
If we had classified health worker as rich if they earned .pdf
 

Recently uploaded

Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
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
 

Recently uploaded (20)

Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
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
 

maincpp include ListItemh include ltstringgt in.pdf

  • 1. (main.cpp) #include "ListItem.h" #include <string> #include <list> #include <vector> #include <algorithm> #include <iostream> using namespace std; int main () { // working with a vector of ints int myints[] = { 5, 10, 15, 20 }; std::vector<int> vectorOfNums (myints,myints+4); std::vector<int>::iterator vectItr; // TODO: write call to find() to search for 15 in the vectorOfNums if (vectItr != vectorOfNums.end()) std::cout << "Element found: " << *vectItr << 'n'; else std::cout << "Element not foundn"; // TODO: write call to find() to search for 85 in the vectorOfNums if (vectItr != vectorOfNums.end()) std::cout << "Element found: " << *vectItr << 'n'; else std::cout << "Element not foundn"; // working with a list of strings std::list<std::string> listOfWords; std::list<std::string>::iterator listIter; listOfWords.push_back("house"); listOfWords.push_back("cup"); listOfWords.push_back("car"); listOfWords.push_back("lamp"); // TODO: write call to find() to search for 'lamp' in the listOfWords and write // the code to test for it // TODO: write call to find() to search for 'music' in the listOfWords and write // the code to test for it // working with a list of listItems std::list<ListItem> listOfItems; std::list<ListItem>::iterator listItemIter; listOfItems.push_back(ListItem("shoes", 150.95)); listOfItems.push_back(ListItem("laptop", 1245.85)); listOfItems.push_back(ListItem("dress", 85.68));
  • 2. listOfItems.push_back(ListItem("polo shirt", 25.67)); // TODO: write call to find() to search for the 'dress' object in the listOfItems and write // the code to test for it // TODO: write call to find() to search for the 'slacks' object that cost '85.68' in the listOfItems and write // the code to test for it return 0; } (ListItem.h) #ifndef LISTITEMH #define LISTITEMH #include <string> using namespace std; class ListItem { public: ListItem(); ListItem(string itemInit, double priceInit); // Print this node void PrintNodeData(); // TODO: write the prototype for the '==' overload // TODO: write the prototype for '<<' overload (hint: must be a friend) private: string item; double price; }; #endif (ListIem.cpp) #include "ListItem.h" #include <iostream> ListItem::ListItem() { item = ""; price = 0.0; } ListItem::ListItem(string itemInit, double priceInit) { item = itemInit; price = priceInit; } // Print this node
  • 3. void ListItem::PrintNodeData() { cout << item << ": $" << price << endl; } // TODO: write the definition for the '==' overload // TODO: write the prototype for '<<' overload Given a Listitem class, complete main() using algorithms from the STL (STL Algorithms). An example algorithm the find(): find (Inputiterator first, Inputiterator last, const T& val) The find uses two iterators for the bounds of the search, first and last. The 3rd parameter is the value being searched for. if we look inside the find() we might see code like this (ref cplusplus.com): The description of find () states "The function uses operator== to compare the individual elements to val". This means that any object we want to search for needs to be have the capability of performing ==. And this may mean implementing the overload if the data type of the object does not already have this overload. Note that C++ types like int, float, double, and string already support this. Your task is to follow the prompts in main() and write the code required. For some of the tests, you will need to provide support for overloaded operators in the Listltem class. 419632.1188960.q3zqy7