Question: CHALLENGE ACTIVITY 9.5.2: Linked list negative values counting. Assign negativeCntr with the number of negative values in the linked list. 347538.2318274.qx3zqy7 1 test passed All

 CHALLENGE ACTIVITY 9.5.2: Linked list negative values counting. Assign negativeCntr with

the number of negative values in the linked list. 347538.2318274.qx3zqy7 1 test

passed All tests passed 1 #include 2 #include 3 using namespace std;4 5 class IntNode { 6 public: 7 IntNode(int dataInit = 0,IntNode* nextLoc = nullptr); 8 void InsertAfter(IntNode* nodeLoc); 9 IntNode* GetNext(); 10

CHALLENGE ACTIVITY 9.5.2: Linked list negative values counting. Assign negativeCntr with the number of negative values in the linked list. 347538.2318274.qx3zqy7 1 test passed All tests passed 1 #include 2 #include 3 using namespace std; 4 5 class IntNode { 6 public: 7 IntNode(int dataInit = 0, IntNode* nextLoc = nullptr); 8 void InsertAfter(IntNode* nodeLoc); 9 IntNode* GetNext(); 10 int GetDataVal; 11 private: 12 int dataval; 13 IntNode* nextNodePtr; 14 }; 15 Run Feedback? 17 IntNode:: IntNode(int dataInit, IntNode* nextLoc) { 18 this->dataVal = dataInit; 19 this->nextNodePtr = nextLoc; 20 } 21 22 /* Insert node after this node. 23 * Before: this -- next 24 * After: this -- node -- next 25 */ 26 void IntNode::InsertAfter(IntNode* nodeloc) { 27 IntNode* tmpNext = nullptr; 28 29 tmpNext = this->nextNodePtr; // Remember next 30 this->nextNodePtr = nodeLoc; // this node 31 nodeLoc->nextNodePtr = tmpNext; // this node ? next 323 34 // Grab Location pointed by nextNodePtr 35 IntNode* IntNode::GetNext() { 36 return this->nextNodePtr; 37 } 38 39 int IntNode:: GetDataVal() { 40 return this->dataval; 41 } 42 43 int main() { 44 IntNode* headObj = nullptr; // Create intNode objects 45 IntNode* currObj = nullptr; 46 IntNode* lastObj = nullptr; 47 int i; 48 int negativeCntr; 49 341330.23 4. // Front of nodes list headObj = new IntNode(-1); lastObj = headObj; 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 for (i = 0; i InsertAfter(currObj); // Append curr lastObj = currObj; // Curr is the new last item } currObj - headObj; // Print the list while (currObj != nullptr) { cout GetDataVal() ", "; currObj = currObj->GetNextO; } cout GetDataVal() ", "; 64 currObj = currObj->GetNext; 65 } 66 cout GetNext; 74 } 75 cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!