Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Main CPP #include #include #include #includeNode.h using namespace std; using namespace linkedlistofclasses; //Function to display void displayList(NodePtr &head) { NodePtr tempPtr = head; while(tempPtr!= NULL){
Main CPP #include#include #include #include"Node.h" using namespace std; using namespace linkedlistofclasses; //Function to display void displayList(NodePtr &head) { NodePtr tempPtr = head; while(tempPtr!= NULL){ cout<< getData() < >error: use of undeclared identifier tempPtr = tempPtr -> getLink(); } cout <getData() == "Joules"){ lastPtr -> setLink(tempPtr -> getLink()); break; } else{ //move ahead in the list lastPtr = tempPtr; tempPtr = tempPtr -> getLink(); } } cout << "After moving Joules, list become: "< getLink(); delete nodeToDelete; } cout << "All node deleted. Sayonara!" << endl; return 0; }
Node CPP
#include#include #include #include"Node.h" namespace linkedlistofclasses { //Define the constructors and a set of accessor and mutator methods Node :: Node() : data(""),link(NULL){ } Node :: Node(string val, Node *next) : data(val), link(next){ } //get the data value for this node string Node::getData() const{ return data; } // Get the next node in the list Node*Node::getLink() const { return link; } //Modify the data value in the node void Node::setData(string val){ data = val; } // Change the reference to =next node void Node::setLink(Node *next){ link = next; } }
Node.h -> Header File
#ifndef HOMEWORK_2_NODE_H #define HOMEWORK_2_NODE_H #include#include #include #include"Node.h" using namespace std; namespace linkedlistofclasses { class Node{ public: Node(); Node (string val, Node *next); string getData() const; //Get the next node in the list Node *getLink() const; void setData(string val); void setLink(Node *next); private: string data; Node *link; }; typedef Node*NodePtr; } #endif //HOMEWORK_2_NODE_H
In C++, can you help me why do I keep getting this message at the displayList function in the main.cpp.
Thank you!
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