Question Details

[solution] » newNode->setNext(currentNode->getNext()); sir can you please tell

Brief item decscription

Step-by-step solution file


Item details:

newNode->setNext(currentNode->getNext()); sir can you please tell
More:

newNode->setNext(currentNode->getNext());

sir can you please tell what happen in this line 

line049 in code


#include

 

<iostream>

 

#include

 

<stdlib.h>

 

using namespace std;

 

/* The Node class */

 

class

 

Node

 

{

 

public:

 

int

 

get() { return

 

object; };

 

void

 

set(int

 

object) { this->object

 

Node

 

void

 

nextNode; }; object; }; * getNext() { return

 

nextNode; };

 

setNext(Node

 

* nextNode) { this->nextNode private:

 

int

 

object;

 

Node

 

* nextNode;

 

};

 

/* The List class */

 

class

 

List

 

{ private:

 

int

 

Node *

 

Node *

 

Node * = size;

 

headNode;

 

currentNode;

 

lastCurrentNode; public:

 

List()

 

{

 

headNode

 

=

 

new Node();

 

headNode->setNext(NULL);

 

currentNode

 

=

 

NULL;

 

lastCurrentNode =

 

NULL;

 

size

 

=

 

0;

 

}

 

void

 

add (int

 

addObject)

 

{

 

Node *

 

newNode

 

=

 

new

 

Node();

 

newNode->set(addObject);

 

if( currentNode

 

!=

 

NULL )

 

{

 

newNode->setNext(currentNode->getNext());

 

currentNode->setNext( newNode );

 

lastCurrentNode

 

=

 

currentNode;

 

currentNode

 

=

 

newNode;

 

}

 

else

 

{

 

newNode->setNext(NULL);

 

headNode->setNext(newNode);

 

lastCurrentNode

 

=

 

headNode;

 

currentNode

 

=

 

newNode;

 

}

 

size ++;

 

}

 

void display() = { int i=1;

 

Node *p;

 

p=headNode->getNext();

 

while(p!=NULL)

 

{

 

cout<<"element "<<i<<"is :"<<p->get();

 

cout<<endl;

 

p=p->getNext();

 

i++;

 

}

 

cout<<"size of link list is:"<<size; }

 

};

 

/* add() class method */

 

main()

 

{ List

 

list;

 

while(1)

 

{

 

cout<<" enter 1 for insertion

 

";

 

cout<<"enter 2 for display

 

";

 

cout<<" enter 3 to exit

 

";

 

int op;

 

cin>>op;

 

switch(op)

 

{

 

case 1:

 

{ } int val;

 

cout<<" enter value you want to insert

 

";

 

cin>>val;

 

list.add(val);

 

break;

 

case 2:

 

{

 

list.display();

 

break; }

 

case 3:

 

exit(0);

 

break; }//end of switch

 

}//end of while

 

}//end of main

 







About this question:
STATUS
Answered
QUALITY
Approved
ANSWER RATING

This question was answered on: Feb 21, 2020

PRICE: $24

Solution~00065725965.zip (18.37 KB)

Buy this answer for only: $24

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy (Deadline assured. Flexible pricing. TurnItIn Report provided)

Pay using PayPal (No PayPal account Required) or your credit card. All your purchases are securely protected by PayPal.
SiteLock

Need a similar solution fast, written anew from scratch? Place your own custom order

We have top-notch tutors who can help you with your essay at a reasonable cost and then you can simply use that essay as a template to build your own arguments. This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student. New solution orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

Order Now