Question: listrec.cpp #include #include listrec.h #include stacklnk.cpp template void List ::stackWriteMirror() const { Stack tempstack; ListNode *a; a = head; while (a != 0) { tempstack.push(a);

listrec.cpp #include #include "listrec.h" #include "stacklnk.cpp"

template void List::stackWriteMirror() const { Stack> tempstack; ListNode *a; a = head; while (a != 0) { tempstack.push(a); a = a->next; } while (!tempstack.empty()) { a = tempstack.pop(); std::cout << a->element; a = a->next; } } listrec.h template < class LE > class ListNode; template < class LE > class List;

template < class LE > class ListNode // Facilitator class for the List class { private:

// Constructor ListNode(const LE &elem, ListNode *nextPtr);

// Data members LE element; // List element ListNode *next; // Pointer to the next element

friend class List; };

template < class LE > class List { public:

void stackWriteMirror() const; // In-lab Exercise 1 private:

// Data members ListNode *head, // Pointer to the beginning of the list *cursor; // Cursor pointer }; stacklnk.cpp #include #include "stacklnk.h"

template < class SE > StackNode::StackNode(const SE &elem, StackNode *nextPtr) : element(elem), next(nextPtr) {}

template < class SE > void Stack::push(const SE &newElement) { top = new StackNode(newElement, top); assert(top != 0); } template < class SE > SE Stack::pop() { StackNode *p; // Pointer to popped node SE temp; // Temporarily stores popped element

assert(top != 0); // Requires that the stack is not empty

temp = top->element; p = top; top = top->next; delete p;

return temp; } stacklnk.h template < class SE > class Stack; template < class SE > class StackNode;

template < class SE > class StackNode // Facilitator class for the Stack class { private:

// Constructor StackNode(const SE &elem, StackNode *nextPtr);

// Data members SE element; // Stack element StackNode *next; // Pointer to the next element

friend class Stack; }; template < class SE > class Stack { public:

// Constructor Stack(int ignored = 0);

void push(const SE &newElement); // Push element SE pop(); // Pop element void clear(); // Clear stack

// Stack status operations int empty() const; // Stack is empty int full() const; // Stack is full

private:

// Data member StackNode *top; // Pointer to the top element };

stackWritemirror() 2 errors :void Stack :: push (const SE &): Can not convert argument 1 from ListNode * to const SE &.

Can not convert from '=' SE to ListNode *.

I don't know how to fix.

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!