Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Linked List - Total Write the body for the total function: int total(Node * current) Notice that the function is not templated. This function will

Linked List - Total

Write the body for the total function:

int total(Node* current)

Notice that the function is not templated. This function will only work with Nodes that contain integers. It is safe to assume in it that Nodes always contain integers as their element.

image text in transcribed

Code: include 3 using namespace std; 5 templatectypename T 6 class Node 7 public: //Value stored in this node T element; //Next node in list (nullptrend of list) Node* next-nullptr; 10 12 13 14 15i 16 17 18 int total (Nodeint>* current) { 19 //Do not modify anything on or above the line below this 20 //yoUR CODE BELOW 21 //Node must be constructed with a value -stored as element Node (T value) : element (value /YOUR CODE 23 24 //YOUR CODE ABOVE 25 //Do not modify anything on or below the line above this 26 27) 28 29 int main() 30 31 32 Nodecint headnew Nodecint> (5) int totalVal-total (head); cout nextnew Nodeint> (3) totalVal-total (head) cout next->next = new Node (6); totalVal total (head)i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago