Question: Please I need Help Use c++ and show me your output. this is the output i need this is what i'm getting here is my

Please I need Help

Use c++ and show me your output.

this is the output i need

Please I need Help Use c++ and show me your output. this

this is what i'm getting

is the output i need this is what i'm getting here is

here is my code

main.cpp

#include

#include

#include "DB.h"

using namespace std;

int main () { srand (time (0));

DB *db = new DB;

for (int i = 0; i

int value = rand () % 90 + 10;

db->push (value);

}

cout

db->display (cout);

for (int i = 0; i

db->pop ();

}

cout

db->display (cout);

return 0;

}

DB.cpp

#include

#include "DB.h"

using namespace std; DB::DB() { front=NULL; size=0; }

void DB::push(int item)

{

Node* temp = new Node(); temp->data=item; temp->next=NULL;

if(front==NULL) { front=temp; } else { temp->next = front; front = temp;

} size++; }

void DB::pop()

{

Node* temp;

if (front == NULL) { cout

temp = front;

front = front -> next; size--; free(temp);

}

}

DB::~DB()

{ delete this; } void DB::display(ostream &out) { Node *temp; if (front == NULL) { cout next; } out

DB.h

#include "Node.h"

using namespace std; //for ostream

class DB{

private:

Node* front;

int size;

public:

DB();

~DB();

void push(int);

void pop();

void display(ostream &);

};

Node.cpp

#include

#include "Node.h"

using namespace std; Node::Node() { data=-1; next=NULL; } Node::Node(int da, Node* nex)

{ data = da; next = nex; }

Node::~Node()

{ delete this; }

Node.h

#include

struct Node

{

int data; //current data

Node* next;

Node(); //constructor -> initialize the data members

Node(int, Node* = NULL); //constructor with arg

~Node(); //destructor

};

$ ./a.exe DB) : 0x7b18cm DB:: push(14) Node(int, Node*) : @x7b18de DB:: push(29) Node(int, Node*) : ex7b18e DB : : push(67) Node(int, Node*) : @x7b18f@ DB:: push(32) Node(int, Node*) : @x7b1900 DB:: push(10) Node(int, Node*) : @x7b1910 -After pushing 5 integers--- 10 32 67 29 14 DB::pop (@x7b18c0) Node() : @x7b1910 DB::pop (@x7b18cm) -Node() : 0x761900 -----After popping 2 integers 67 29 14 -DB) : @x7b18ce -Node() : @x7b18fe -Node() : @x7b18e Node() : @x7b18de -After pushing 5 Integer- 39 73 38 82 60 --After popping 2 Integer----- 38 82 60

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!