Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can u divide this program in .h and .cpp #include using namespace std; class node { private: int data; node *next; public: node (int); void

can u divide this program in .h and .cpp image text in transcribed
image text in transcribed
image text in transcribed
#include using namespace std; class node { private: int data; node *next; public: node (int); void set(int); int get(); void setNext(node *); node *getNext(); void showData(); }; node::node(int x) { set(x); next = NULL; } void node::set(int x) { data = x; } int node::get() { return data; } void node::setNext(node *ptr) { next = ptr; } node *node::getNext() { return next; } void node::showData() { cout getNext()!= NULL) { currentNode = currentNode->getNext(); } } int LinkedList::get() { if (currentNode != NULL) {return currentNode->get(); }} int LinkedList::length() { return size; } void LinkedList::add(int d) { node *newNode = new node(d); if (size: 0) node *newNode = new node(d); if (size == 0) {currentNode = new Node; headNode = newNode; currentNode->setNext(headNode); } else { newNode->setNext(currentNode- >getNext()); currentNode->setNext(newNode); currentNode = new Node; } size++; } void LinkedList::update(int d) { if (currentNode != NULL) { currentNode->set(d); }} void LinkedList::remove() { if (currentNode != NULL) { if (currentNode != headNode) { node *ptr; ptr = headNode; while (ptr->getNext() != currentNode) { ptr = ptr->getNext(); } coutgetNext()->get() setNext(currentNode->getNext()); currentNode = ptr; size--; } else { currentNode = currentNode->getNext(); node *ptr; ptr = headNode; while (ptr->getNext() != headNode) { ptr = ptr->getNext(); } coutgetNext()->get() setNext(currentNode); ksetNext(currentNode); headNode = currentNode; size--;}} else { cout get() == d) { cout getNext(); } while (ptr != headNode); } void LinkedList::showList() { node *ptr; ptr = headNode; do { ptr->showData(); ptr = ptr->getNext(); } while (ptr != headNode); cout >spaces; for (int i = 1; i >x; l.add(x); } I.showList(); cout 1) { int i; for (i = 0; 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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions