Question: c++ Stack and Node files not compiling right. I have a core dump error showing up at the bool expression. please help. //Node.cpp template Node

c++ Stack and Node files not compiling right. I have a core dump error showing up at the bool expression. please help.

//Node.cpp

template Node::Node(T entry) { m_entry = entry; m_next = nullptr; }

template T Node::getEntry() const { return(m_entry); }

template void Node::setEntry(T entry) { m_entry = entry; }

template Node* Node::getNext() const { return(m_next); }

template void Node::setNext(Node* next) { m_next = next; }

//Stack.cpp

template Stack::Stack(const Stack& orig) { Node* origNodes = orig.m_top; while(origNodes != nullptr) { push(origNodes-> getEntry()); origNodes = origNodes -> getNext(); numPeople++; } }

template void Stack::push(T entry) { Node* temp1 = new Node(entry, m_top); m_top= temp1; numPeople++; }

template bool Stack::isEmpty() { if(m_top == nullptr) {return (true);} else { return(false); } }

template void Stack::pop() { try { Node* temp = m_top; T temp1= m_top -> getEntry(); m_top= temp-> getNext(); delete temp ; numPeople--; } catch(std::runtime_error rte) { std::cout << rte.what(); } }

template T Stack::peek() const { try { return(m_top-> getEntry()); } catch(std::runtime_error rte) { std::cout << rte.what(); return("No one"); } }

template Stack::~Stack() { while (isEmpty()!= false) { m_top->setEntry(nullptr); m_top->getNext(); } delete[] m_top; }

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!