Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For the following problem, please explain what lastNode - > InsertAfter ( currNode ) is doing. I am really confused by the arrow. Also, explain
For the following problem, please explain what lastNodeInsertAftercurrNode is doing. I am really confused by the arrow. Also, explain what lastNode currNode is doing. Those are the most important things for me Please use C
Given the MileageTrackerNode class, complete main to insert nodes into a linked list using the InsertAfter function The first userinput value is the number of nodes in the linked list. Use the PrintNodeData function to print the entire linked list. DO NOT print the dummy head node.
Ex If the input is:
the output is: Results need to output exactly like below no extra zeros please
main.cpp
#include "MileageTrackerNode.h
#include
#include
using namespace std;
int main
References for MileageTrackerNode objects
MileageTrackerNode headNode;
MileageTrackerNode currNode;
MileageTrackerNode lastNode;
double miles;
string date;
int i;
Front of nodes list
headNode new MileageTrackerNode;
lastNode headNode;
TODO: Read in the number of nodes
TODO: For the read in number of nodes, read
in data and insert into the linked list
TODO: Call the PrintNodeData method
to print the entire linked list
MileageTrackerNode Destructor deletes all
following nodes
delete headNode;
MileageTrackerNode.h
#ifndef MILEAGETRACKERNODEH
#define MILEAGETRACKERNODEH
#include
using namespace std;
class MileageTrackerNode
public:
Constructor
MileageTrackerNode;
Destructor
~MileageTrackerNode;
Constructor
MileageTrackerNodedouble milesInit, string dateInit;
Constructor
MileageTrackerNodedouble milesInit, string dateInit, MileageTrackerNode nextLoc;
Insert node after this node.
Before: this next
After: this node next
void InsertAfterMileageTrackerNode nodeLoc;
Get location pointed by nextNodeRef
MileageTrackerNode GetNext;
void PrintNodeData;
private:
double miles; Node data
string date; Node data
MileageTrackerNode nextNodeRef; Reference to the next node
;
#endif
MileageTrackerNode.cpp
#include "MileageTrackerNode.h
#include
Constructor
MileageTrackerNode::MileageTrackerNode
miles ;
date ;
nextNodeRef nullptr;
Destructor
MileageTrackerNode::~MileageTrackerNode
ifnextNodeRef nullptr
delete nextNodeRef;
Constructor
MileageTrackerNode::MileageTrackerNodedouble milesInit, string dateInit
miles milesInit;
date dateInit;
nextNodeRef nullptr;
Constructor
MileageTrackerNode::MileageTrackerNodedouble milesInit, string dateInit, MileageTrackerNode nextLoc
miles milesInit;
date dateInit;
nextNodeRef nextLoc;
Insert node after this node.
Before: this next
After: this node next
void MileageTrackerNode::InsertAfterMileageTrackerNode nodeLoc
MileageTrackerNode tmpNext;
tmpNext nextNodeRef;
nextNodeRef nodeLoc;
nodeLocnextNodeRef tmpNext;
Get location pointed by nextNodeRef
MileageTrackerNode MileageTrackerNode::GetNext
return nextNodeRef;
void MileageTrackerNode::PrintNodeData
cout miles date endl;
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