Question: Compilation failed with errors: / usr / bin / ld: build / main . o: ( . bss + 0 x 0 ) : multiple
Compilation failed with errors:
usrbinld: buildmaino:bssx: multiple definition of DNode::activeNodes'; buildDNodeo:bssx: first defined here
collect: error: ld returned exit status
make: Makefile:: buildmain Error
Recommendation: Check for recursive inclusion, unhandled exceptions, logical errors, or syntax issues in the code.Submission Status: Failed
Automatic Test Results
Compilation failed with errors:
usrbinld: buildmaino:bssx: multiple definition of DNode::activeNodes'; buildDNodeo:bssx: first defined here
collect: error: ld returned exit status
make: Makefile:: buildmain Error Recommendation: Check for recursive inclusion, unhandled exceptions, logical errors, or syntax issues in the code.
pls help here is my code:
DLinkedListcpp
#include "DLinkedList.h
#include
DLinkedList::DLinkedList : headnullptr trailernullptr listSize
DLinkedList::~DLinkedList
while empty removeFront;
bool DLinkedList::empty const
return head nullptr;
const int& DLinkedList::front const
return headelem;
const int& DLinkedList::back const
return trailerelem;
void DLinkedList::addFrontconst int& e
DNode newNode new DNodee nullptr, head;
if empty
head trailer newNode;
else
headprev newNode;
head newNode;
listSize;
void DLinkedList::addBackconst int& e
DNode newNode new DNodee trailer, nullptr;
if empty
head trailer newNode;
else
trailernext newNode;
trailer newNode;
listSize;
void DLinkedList::removeFront
if empty return;
DNode oldNode head;
if head trailer
head trailer nullptr;
else
head headnext;
headprev nullptr;
delete oldNode;
listSize;
void DLinkedList::removeBack
if empty return;
DNode oldNode trailer;
if head trailer
head trailer nullptr;
else
trailer trailerprev;
trailernext nullptr;
delete oldNode;
listSize;
void DLinkedList::printbool front const
if empty return;
if front
DNode node head;
while node nullptr
std::cout nodeelem ;
node nodenext;
else
DNode node trailer;
while node nullptr
std::cout nodeelem ;
node nodeprev;
std::cout std::endl;
int DLinkedList::size const
return listSize;
int DLinkedList::activeNodeCount const
return DNode::activeNodes;
DNodecpp
#include "DNode.h
Define the static member variable
int DNode::activeNodes ;
DNode::DNodeint e DNode p DNode n : eleme prevp nextn
activeNodes;
DNode::~DNode
activeNodes;
DLinkedListh
#ifndef DLINKEDLISTH
#define DLINKEDLISTH
#include "DNode.h
class DLinkedList
private:
DNode head; Pointer to the first node
DNode trailer; Pointer to the last node
int listSize; Stores the current number of elements in the list
public:
DLinkedList; Constructor
~DLinkedList; Destructor
bool empty const; Check if the list is empty
const int& front const; Get front element
const int& back const; Get back element
void addFrontconst int& e; Add to the front of the list
void addBackconst int& e; Add to the back of the list
void removeFront; Remove front item from the list
void removeBack; Remove back item from the list
void printbool front true const; Print the list
int size const; Returns the current number of elements in the list
int activeNodeCount const; Return the count of active DNodes
;
#endif DLINKEDLISTH
maincpp
#include "DLinkedList.h
#include
int main
DLinkedList list;
list.addFront;
list.addFront;
list.addFront;
list.addBack;
list.addBack;
std::cout "List from head: ;
list.printtrue;
std::cout "List from trailer: ;
list.printfalse;
list.removeFront;
list.removeBack;
std::cout "List after removals: ;
list.printtrue;
list.addFront;
list.addBack;
std::cout "List after adding more elements: ;
list.printtrue;
std::cout "Active nodes: list.activeNodeCount std::endl;
return ;
DNodeh
#ifndef DNODEH
#define DNODEH
class DNode
private:
int elem; Element stored in the node
DNode prev; Pointer to the previous node
DNode next; Pointer to the next node
public:
static int activeNodes; Sta
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
