Question: please help me fix this code please use c++ please show your output PLEASE HELP sample output main.cpp #include #include #include DB.h using namespace std;

please help me fix this code

please use c++

please show your output

PLEASE HELP please help me fix this code please use c++ please show your

output PLEASE HELP sample output 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); delete db; return 0; } Node.cpp

#include #include "Node.h" using namespace std; Node::Node(int da, Node* nex) { data

sample output = da; next = nex; } Node::~Node() { delete this; } Node.h

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);

delete db;

return 0;

}

Node.cpp

#include

#include "Node.h"

using namespace std;

Node::Node(int da, Node* nex)

{

data = da;

next = nex;

}

Node::~Node()

{

delete this;

}

Node.h

#include

struct Node

{

int data; //current student

Node* next;

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

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

~Node(); //destructor

};

DB.h

#ifndef DB_H

#define DB_H

#include

#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&);

};

#endif

DB.cpp

#include

#include "DB.h"

using namespace std;

void DB::push(int item)

{

Node* temp = new Node();

if (!temp)

{

cout

exit(1);

}

else

{

temp->data = item;

temp->next = front;

front = temp;

}

}

void DB::pop()

{

Node* temp;

if (front == NULL)

{

cout

}

else

{

temp = front;

front = front -> next;

temp->next = NULL;

free(temp);

}

}

DB::~DB()

{

delete this;

}

GDB.CPP C Node.h C DB.h Node* temp main.cpp Node.cpp E DB.cpp >... 1 #include 2 #include "OB.h" 3 4 using namespace std; 5 6 void DB::push(int ites) 7 { 8 - new Node(); 9 10 if (Itemp) 11 { 12 cout data - iten; 18 temp->next = front; 19 front - temp: 28 } 21 22 23 void DB::pop() 24 { 25 Node* temp; 26 if (front NULL) 27 { 28 cout next; 34 temp->next = NULL; 35 free(temp); 36 37 } 38 39 40 08:1-08) 41 42 delete this; 43 code.cpp * G DB.cpp Gmain.cpp Node.cpp > 1 #include 2 #include "Node.h" using namespace std; 3 4 5 6 7 8 9 10 11 12 13 14 Node::Node(int da, Node* nex) { data - da; next nex; Node::lode() { | delete this; } 3 Node.h> 1 #include 2 struct Node 4 { 5 int data; //current student Node* next; 7 Node(); //constructor -> initialize the data members Node(int, Node* - nullptr); //constructor with arg 9 lode(); //destructor 10 }; 6 8 Node C DB.h>... 1 #ifndef DB_H 2 #define DB_H 3 #include 4 #include "Node.h" 5 6 using namespace std; //for ostream 7 8 class DB{ 9 private: 10 Node* front; 11 int size; 12 public: 13 DB(); 14 DB(); 15 void push(int); 16 void pop(); 17 void display(ostream&); 18 19 20 #endif M makefile 1 #one colony: dependancy 2 3 a.exe: -Node.o DB.O main.o 4 g++ Node.o DB.o main.o -0.exe 5 Node.o: Node.h Node.cpp 6 g++ -c Node.cpp DB.O: Node.h DB.h DB.cpp g++ -C DB.cpp 9 main.o: DB.h main.cpp 10 g++ -c main.cpp 11 clean: 12 rm .o a.exe 13 14 15 78 $ /a.exe DB) : @x7b18ce DB::push(14) Node(int, Node*) : @x7b18de DB:: push(29) Node(int, Node*) : @x7b18ee DB:: push(67) Node(int, Node*) : @x7b18fe DB:: push(32) Node(int, Node*) : ex7b1900 DB:: push(10) Node(int, Node") : 0x7b1910 -----After pushing 5 integers-- 10 32 67 29 14 DB:: pop (@ x8ce) Node(): 0x761910 DB:: pop (@x7b18ce) Node() : @x7b1900 ----After popping 2 integers- 67 29 14 -DB() : 0x7b18ce -Node(): 0x7b18f0 -Node() : @x7b18e -Node() : @x7b18de

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!