SlideShare a Scribd company logo
1 of 5
// main.cpp
#include <iostream>
#include "ContactNode.h"
int main() {
ContactNode* contactList = new ContactNode();
ContactNode* currNode;
std::string name, phoneNum;
int i = 1;
while (i <= 3) {
std::cout << "Person " << i++ << std::endl;
std::cout << "Enter name:" << std::endl;
getline(std::cin, name);
std::cout << "Enter phone number:" << std::endl;
std::cin >> phoneNum;
std::cin.ignore();
contactList->InsertAfter(new ContactNode(name, phoneNum));
std::cout << "You entered: " << name << ", " << phoneNum << std::endl << std::endl;
}
currNode = contactList;
std::cout << "CONTACT LIST" << std::endl;
while (contactList != nullptr) {
currNode->PrintContactNode();
currNode = currNode->GetNext();
}
delete contactList, currNode;
}
// ContactNode.h
#ifndef CONTACTNODE_H
#define CONTACTNODE_H
#include <string>
class ContactNode {
public:
ContactNode(std::string contactName = "", std::string contactPhoneNum = "") {
this->contactName = contactName;
this->contactPhoneNum = contactPhoneNum;
}
~ContactNode();
ContactNode& operator=(const ContactNode& objToCopy);
void InsertAfter(ContactNode*);
std::string GetName() const;
std::string GetPhoneNumber() const;
ContactNode *GetNext() const;
void PrintContactNode();
private:
std::string contactName;
std::string contactPhoneNum;
ContactNode* nextNodePtr = nullptr;
};
#endif
// ContactNode.cpp
#include <iostream>
#include "ContactNode.h"
void ContactNode::InsertAfter(ContactNode* newNode) {
ContactNode *tmpNext = this->nextNodePtr;
this->nextNodePtr = newNode;
newNode->nextNodePtr = tmpNext;
}
ContactNode::~ContactNode() {
ContactNode* curr = nextNodePtr;
delete nextNodePtr;
while (curr != nullptr) {
curr = nextNodePtr;
delete nextNodePtr;
}
}
ContactNode& ContactNode::operator=(const ContactNode& objToCopy) {
if (this != &objToCopy) {
delete nextNodePtr;
nextNodePtr = new ContactNode();
*nextNodePtr = *(objToCopy.nextNodePtr);
}
return *this;
}
std::string ContactNode::GetName() const {
return contactName;
}
std::string ContactNode::GetPhoneNumber() const {
return contactPhoneNum;
}
ContactNode* ContactNode::GetNext() const{
return this->nextNodePtr;
}
void ContactNode::PrintContactNode() {
std::cout << "Name: " << contactName << "nPhone Number: " << contactPhoneNum <<
std::endl;
}
// Can you fix my code, if you use copy and paste a different code than mine I will give a thumbs
down.
-- main-cpp #include -iostream- #include -ContactNode-h-   int main().docx

More Related Content

Similar to -- main-cpp #include -iostream- #include -ContactNode-h- int main().docx

So here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdfSo here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdfleolight2
 
ch5_additional.ppt
ch5_additional.pptch5_additional.ppt
ch5_additional.pptLokeshK66
 
PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
 PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdfannamalaiagencies
 
#include iostream#include stringusing namespace std;.docx
#include iostream#include stringusing namespace std;.docx#include iostream#include stringusing namespace std;.docx
#include iostream#include stringusing namespace std;.docxkatherncarlyle
 
Bank management system project in c++ with graphics
Bank management system project in c++ with graphicsBank management system project in c++ with graphics
Bank management system project in c++ with graphicsVtech Academy of Computers
 
Help with the following code1. Rewrite to be contained in a vecto.pdf
Help with the following code1. Rewrite to be contained in a vecto.pdfHelp with the following code1. Rewrite to be contained in a vecto.pdf
Help with the following code1. Rewrite to be contained in a vecto.pdfezzi97
 
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
 
Please use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdfPlease use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdfseoagam1
 
[KOSSA] C++ Programming - 16th Study - STL #2
[KOSSA] C++ Programming - 16th Study - STL #2[KOSSA] C++ Programming - 16th Study - STL #2
[KOSSA] C++ Programming - 16th Study - STL #2Seok-joon Yun
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdffantoosh1
 
#include iostream #include fstream #include cstdlib #.pdf
 #include iostream #include fstream #include cstdlib #.pdf #include iostream #include fstream #include cstdlib #.pdf
#include iostream #include fstream #include cstdlib #.pdfannesmkt
 
ch6_additional.ppt
ch6_additional.pptch6_additional.ppt
ch6_additional.pptLokeshK66
 

Similar to -- main-cpp #include -iostream- #include -ContactNode-h- int main().docx (20)

So here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdfSo here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdf
 
ch5_additional.ppt
ch5_additional.pptch5_additional.ppt
ch5_additional.ppt
 
PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
 PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
 
Computer Programming- Lecture 7
Computer Programming- Lecture 7Computer Programming- Lecture 7
Computer Programming- Lecture 7
 
#include iostream#include stringusing namespace std;.docx
#include iostream#include stringusing namespace std;.docx#include iostream#include stringusing namespace std;.docx
#include iostream#include stringusing namespace std;.docx
 
C++ L06-Pointers
C++ L06-PointersC++ L06-Pointers
C++ L06-Pointers
 
Oopppp
OoppppOopppp
Oopppp
 
oodp elab.pdf
oodp elab.pdfoodp elab.pdf
oodp elab.pdf
 
Bank management system project in c++ with graphics
Bank management system project in c++ with graphicsBank management system project in c++ with graphics
Bank management system project in c++ with graphics
 
Cmptr ass
Cmptr assCmptr ass
Cmptr ass
 
Help with the following code1. Rewrite to be contained in a vecto.pdf
Help with the following code1. Rewrite to be contained in a vecto.pdfHelp with the following code1. Rewrite to be contained in a vecto.pdf
Help with the following code1. Rewrite to be contained in a vecto.pdf
 
maincpp include ListItemh include ltstringgt in.pdf
maincpp include ListItemh include ltstringgt in.pdfmaincpp include ListItemh include ltstringgt in.pdf
maincpp include ListItemh include ltstringgt in.pdf
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
 
Please use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdfPlease use the code below and make it operate as one program- Notating.pdf
Please use the code below and make it operate as one program- Notating.pdf
 
[KOSSA] C++ Programming - 16th Study - STL #2
[KOSSA] C++ Programming - 16th Study - STL #2[KOSSA] C++ Programming - 16th Study - STL #2
[KOSSA] C++ Programming - 16th Study - STL #2
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
 
#include iostream #include fstream #include cstdlib #.pdf
 #include iostream #include fstream #include cstdlib #.pdf #include iostream #include fstream #include cstdlib #.pdf
#include iostream #include fstream #include cstdlib #.pdf
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
ch6_additional.ppt
ch6_additional.pptch6_additional.ppt
ch6_additional.ppt
 

More from AndrewGmjOliverf

- Use the ISD model of training and development to examine one of your.docx
- Use the ISD model of training and development to examine one of your.docx- Use the ISD model of training and development to examine one of your.docx
- Use the ISD model of training and development to examine one of your.docxAndrewGmjOliverf
 
- viridae means in virus taxonomy family genus Question 16 2-5pts DNA.docx
- viridae means in virus taxonomy family genus Question 16 2-5pts DNA.docx- viridae means in virus taxonomy family genus Question 16 2-5pts DNA.docx
- viridae means in virus taxonomy family genus Question 16 2-5pts DNA.docxAndrewGmjOliverf
 
- The Excess Burden of a Tax is- a- a tax that prevents market interac.docx
- The Excess Burden of a Tax is- a- a tax that prevents market interac.docx- The Excess Burden of a Tax is- a- a tax that prevents market interac.docx
- The Excess Burden of a Tax is- a- a tax that prevents market interac.docxAndrewGmjOliverf
 
- Please use the drag-and-drop environment to label the missing parts.docx
- Please use the drag-and-drop environment to label the missing parts.docx- Please use the drag-and-drop environment to label the missing parts.docx
- Please use the drag-and-drop environment to label the missing parts.docxAndrewGmjOliverf
 
- Let's assume that CSU Global maintains its students' information in.docx
- Let's assume that CSU Global maintains its students' information in.docx- Let's assume that CSU Global maintains its students' information in.docx
- Let's assume that CSU Global maintains its students' information in.docxAndrewGmjOliverf
 
- Let X be a random variable has a normal distribution with -30 and -1.docx
- Let X be a random variable has a normal distribution with -30 and -1.docx- Let X be a random variable has a normal distribution with -30 and -1.docx
- Let X be a random variable has a normal distribution with -30 and -1.docxAndrewGmjOliverf
 
- Do you think that the problems at Andersen were unique to them or di.docx
- Do you think that the problems at Andersen were unique to them or di.docx- Do you think that the problems at Andersen were unique to them or di.docx
- Do you think that the problems at Andersen were unique to them or di.docxAndrewGmjOliverf
 
- Define scope of project - Identify stakeholders- decision-makers- an.docx
- Define scope of project - Identify stakeholders- decision-makers- an.docx- Define scope of project - Identify stakeholders- decision-makers- an.docx
- Define scope of project - Identify stakeholders- decision-makers- an.docxAndrewGmjOliverf
 
- Describe the difference between an operating system and application.docx
- Describe the difference between an operating system and application.docx- Describe the difference between an operating system and application.docx
- Describe the difference between an operating system and application.docxAndrewGmjOliverf
 
- Differential tax incidence measures the effect- a- that a tax and th.docx
- Differential tax incidence measures the effect- a- that a tax and th.docx- Differential tax incidence measures the effect- a- that a tax and th.docx
- Differential tax incidence measures the effect- a- that a tax and th.docxAndrewGmjOliverf
 
- Are outside financial analysts helpful or hurtful to investors- - Do.docx
- Are outside financial analysts helpful or hurtful to investors- - Do.docx- Are outside financial analysts helpful or hurtful to investors- - Do.docx
- Are outside financial analysts helpful or hurtful to investors- - Do.docxAndrewGmjOliverf
 
) star b) TCP-IP c) token ring d) Ethernet Question 3.docx
)  star     b)  TCP-IP     c)  token ring     d)  Ethernet Question 3.docx)  star     b)  TCP-IP     c)  token ring     d)  Ethernet Question 3.docx
) star b) TCP-IP c) token ring d) Ethernet Question 3.docxAndrewGmjOliverf
 
(t) Cravin Pis t 1+ fir ax+1 orias in 814 3- -1-4 Reinte- ortais- pari.docx
(t) Cravin Pis t 1+ fir ax+1 orias in 814 3- -1-4 Reinte- ortais- pari.docx(t) Cravin Pis t 1+ fir ax+1 orias in 814 3- -1-4 Reinte- ortais- pari.docx
(t) Cravin Pis t 1+ fir ax+1 orias in 814 3- -1-4 Reinte- ortais- pari.docxAndrewGmjOliverf
 
(Round to the nowet cent is neededCick the icos to view the lable et c.docx
(Round to the nowet cent is neededCick the icos to view the lable et c.docx(Round to the nowet cent is neededCick the icos to view the lable et c.docx
(Round to the nowet cent is neededCick the icos to view the lable et c.docxAndrewGmjOliverf
 
(Q001) Scenario Caittyn is a very social high school sophomore- Her wo.docx
(Q001) Scenario Caittyn is a very social high school sophomore- Her wo.docx(Q001) Scenario Caittyn is a very social high school sophomore- Her wo.docx
(Q001) Scenario Caittyn is a very social high school sophomore- Her wo.docxAndrewGmjOliverf
 
(Q010) What additional actions (at least 3) should be taken with regar.docx
(Q010) What additional actions (at least 3) should be taken with regar.docx(Q010) What additional actions (at least 3) should be taken with regar.docx
(Q010) What additional actions (at least 3) should be taken with regar.docxAndrewGmjOliverf
 
(Questien 12 of 12 ) economy experanced an inceste of 20- in ta popula.docx
(Questien 12 of 12 ) economy experanced an inceste of 20- in ta popula.docx(Questien 12 of 12 ) economy experanced an inceste of 20- in ta popula.docx
(Questien 12 of 12 ) economy experanced an inceste of 20- in ta popula.docxAndrewGmjOliverf
 
(Q007) Diagnosis When the laboratory results come back- the physician.docx
(Q007) Diagnosis When the laboratory results come back- the physician.docx(Q007) Diagnosis When the laboratory results come back- the physician.docx
(Q007) Diagnosis When the laboratory results come back- the physician.docxAndrewGmjOliverf
 
(Present value of annuities and complex cash flows) You are given thre.docx
(Present value of annuities and complex cash flows) You are given thre.docx(Present value of annuities and complex cash flows) You are given thre.docx
(Present value of annuities and complex cash flows) You are given thre.docxAndrewGmjOliverf
 
(i) 2131+1+133 Sitition ats- fremiaks- sute sose.docx
(i) 2131+1+133 Sitition ats- fremiaks- sute sose.docx(i) 2131+1+133 Sitition ats- fremiaks- sute sose.docx
(i) 2131+1+133 Sitition ats- fremiaks- sute sose.docxAndrewGmjOliverf
 

More from AndrewGmjOliverf (20)

- Use the ISD model of training and development to examine one of your.docx
- Use the ISD model of training and development to examine one of your.docx- Use the ISD model of training and development to examine one of your.docx
- Use the ISD model of training and development to examine one of your.docx
 
- viridae means in virus taxonomy family genus Question 16 2-5pts DNA.docx
- viridae means in virus taxonomy family genus Question 16 2-5pts DNA.docx- viridae means in virus taxonomy family genus Question 16 2-5pts DNA.docx
- viridae means in virus taxonomy family genus Question 16 2-5pts DNA.docx
 
- The Excess Burden of a Tax is- a- a tax that prevents market interac.docx
- The Excess Burden of a Tax is- a- a tax that prevents market interac.docx- The Excess Burden of a Tax is- a- a tax that prevents market interac.docx
- The Excess Burden of a Tax is- a- a tax that prevents market interac.docx
 
- Please use the drag-and-drop environment to label the missing parts.docx
- Please use the drag-and-drop environment to label the missing parts.docx- Please use the drag-and-drop environment to label the missing parts.docx
- Please use the drag-and-drop environment to label the missing parts.docx
 
- Let's assume that CSU Global maintains its students' information in.docx
- Let's assume that CSU Global maintains its students' information in.docx- Let's assume that CSU Global maintains its students' information in.docx
- Let's assume that CSU Global maintains its students' information in.docx
 
- Let X be a random variable has a normal distribution with -30 and -1.docx
- Let X be a random variable has a normal distribution with -30 and -1.docx- Let X be a random variable has a normal distribution with -30 and -1.docx
- Let X be a random variable has a normal distribution with -30 and -1.docx
 
- Do you think that the problems at Andersen were unique to them or di.docx
- Do you think that the problems at Andersen were unique to them or di.docx- Do you think that the problems at Andersen were unique to them or di.docx
- Do you think that the problems at Andersen were unique to them or di.docx
 
- Define scope of project - Identify stakeholders- decision-makers- an.docx
- Define scope of project - Identify stakeholders- decision-makers- an.docx- Define scope of project - Identify stakeholders- decision-makers- an.docx
- Define scope of project - Identify stakeholders- decision-makers- an.docx
 
- Describe the difference between an operating system and application.docx
- Describe the difference between an operating system and application.docx- Describe the difference between an operating system and application.docx
- Describe the difference between an operating system and application.docx
 
- Differential tax incidence measures the effect- a- that a tax and th.docx
- Differential tax incidence measures the effect- a- that a tax and th.docx- Differential tax incidence measures the effect- a- that a tax and th.docx
- Differential tax incidence measures the effect- a- that a tax and th.docx
 
- Are outside financial analysts helpful or hurtful to investors- - Do.docx
- Are outside financial analysts helpful or hurtful to investors- - Do.docx- Are outside financial analysts helpful or hurtful to investors- - Do.docx
- Are outside financial analysts helpful or hurtful to investors- - Do.docx
 
) star b) TCP-IP c) token ring d) Ethernet Question 3.docx
)  star     b)  TCP-IP     c)  token ring     d)  Ethernet Question 3.docx)  star     b)  TCP-IP     c)  token ring     d)  Ethernet Question 3.docx
) star b) TCP-IP c) token ring d) Ethernet Question 3.docx
 
(t) Cravin Pis t 1+ fir ax+1 orias in 814 3- -1-4 Reinte- ortais- pari.docx
(t) Cravin Pis t 1+ fir ax+1 orias in 814 3- -1-4 Reinte- ortais- pari.docx(t) Cravin Pis t 1+ fir ax+1 orias in 814 3- -1-4 Reinte- ortais- pari.docx
(t) Cravin Pis t 1+ fir ax+1 orias in 814 3- -1-4 Reinte- ortais- pari.docx
 
(Round to the nowet cent is neededCick the icos to view the lable et c.docx
(Round to the nowet cent is neededCick the icos to view the lable et c.docx(Round to the nowet cent is neededCick the icos to view the lable et c.docx
(Round to the nowet cent is neededCick the icos to view the lable et c.docx
 
(Q001) Scenario Caittyn is a very social high school sophomore- Her wo.docx
(Q001) Scenario Caittyn is a very social high school sophomore- Her wo.docx(Q001) Scenario Caittyn is a very social high school sophomore- Her wo.docx
(Q001) Scenario Caittyn is a very social high school sophomore- Her wo.docx
 
(Q010) What additional actions (at least 3) should be taken with regar.docx
(Q010) What additional actions (at least 3) should be taken with regar.docx(Q010) What additional actions (at least 3) should be taken with regar.docx
(Q010) What additional actions (at least 3) should be taken with regar.docx
 
(Questien 12 of 12 ) economy experanced an inceste of 20- in ta popula.docx
(Questien 12 of 12 ) economy experanced an inceste of 20- in ta popula.docx(Questien 12 of 12 ) economy experanced an inceste of 20- in ta popula.docx
(Questien 12 of 12 ) economy experanced an inceste of 20- in ta popula.docx
 
(Q007) Diagnosis When the laboratory results come back- the physician.docx
(Q007) Diagnosis When the laboratory results come back- the physician.docx(Q007) Diagnosis When the laboratory results come back- the physician.docx
(Q007) Diagnosis When the laboratory results come back- the physician.docx
 
(Present value of annuities and complex cash flows) You are given thre.docx
(Present value of annuities and complex cash flows) You are given thre.docx(Present value of annuities and complex cash flows) You are given thre.docx
(Present value of annuities and complex cash flows) You are given thre.docx
 
(i) 2131+1+133 Sitition ats- fremiaks- sute sose.docx
(i) 2131+1+133 Sitition ats- fremiaks- sute sose.docx(i) 2131+1+133 Sitition ats- fremiaks- sute sose.docx
(i) 2131+1+133 Sitition ats- fremiaks- sute sose.docx
 

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
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
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
 
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
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
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
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
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
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
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
 
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
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 

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.
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
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
 
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
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
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...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
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
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
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
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
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
 
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
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 

-- main-cpp #include -iostream- #include -ContactNode-h- int main().docx

  • 1. // main.cpp #include <iostream> #include "ContactNode.h" int main() { ContactNode* contactList = new ContactNode(); ContactNode* currNode; std::string name, phoneNum; int i = 1; while (i <= 3) { std::cout << "Person " << i++ << std::endl; std::cout << "Enter name:" << std::endl; getline(std::cin, name); std::cout << "Enter phone number:" << std::endl; std::cin >> phoneNum; std::cin.ignore(); contactList->InsertAfter(new ContactNode(name, phoneNum)); std::cout << "You entered: " << name << ", " << phoneNum << std::endl << std::endl; } currNode = contactList; std::cout << "CONTACT LIST" << std::endl; while (contactList != nullptr) { currNode->PrintContactNode(); currNode = currNode->GetNext();
  • 2. } delete contactList, currNode; } // ContactNode.h #ifndef CONTACTNODE_H #define CONTACTNODE_H #include <string> class ContactNode { public: ContactNode(std::string contactName = "", std::string contactPhoneNum = "") { this->contactName = contactName; this->contactPhoneNum = contactPhoneNum; } ~ContactNode(); ContactNode& operator=(const ContactNode& objToCopy); void InsertAfter(ContactNode*); std::string GetName() const; std::string GetPhoneNumber() const; ContactNode *GetNext() const; void PrintContactNode(); private: std::string contactName; std::string contactPhoneNum;
  • 3. ContactNode* nextNodePtr = nullptr; }; #endif // ContactNode.cpp #include <iostream> #include "ContactNode.h" void ContactNode::InsertAfter(ContactNode* newNode) { ContactNode *tmpNext = this->nextNodePtr; this->nextNodePtr = newNode; newNode->nextNodePtr = tmpNext; } ContactNode::~ContactNode() { ContactNode* curr = nextNodePtr; delete nextNodePtr; while (curr != nullptr) { curr = nextNodePtr; delete nextNodePtr; } } ContactNode& ContactNode::operator=(const ContactNode& objToCopy) { if (this != &objToCopy) { delete nextNodePtr; nextNodePtr = new ContactNode();
  • 4. *nextNodePtr = *(objToCopy.nextNodePtr); } return *this; } std::string ContactNode::GetName() const { return contactName; } std::string ContactNode::GetPhoneNumber() const { return contactPhoneNum; } ContactNode* ContactNode::GetNext() const{ return this->nextNodePtr; } void ContactNode::PrintContactNode() { std::cout << "Name: " << contactName << "nPhone Number: " << contactPhoneNum << std::endl; } // Can you fix my code, if you use copy and paste a different code than mine I will give a thumbs down.