首页 > 解决方案 > 我正在努力开始使用堆栈和队列,并且想知道是否有人可以根据这些类提供帮助?

问题描述

#include <iostream>;

using namespace std;

class Node
    {
public:
    Node(int value, Node* nextptr = NULL, Node* prevptr = NULL, int currentpriority = 0);
    int getVal(void);
    Node* getNext(void);
    Node* getPrev(void);
    void setVal(int value);
    void setPrev(Node* prevptr);
    void setNext(Node* nextptr);
    int getPriority(void);
    void setPriority(int priority);
private:
    Node* next;
    Node* prev;
    int priority;
    int value;
};

class Stack
    {
public:
     Stack(void);
    ~Stack(void);
    void Push(int value);
    Node* NodePop(void);
    int Pop(void);
    private:
    Node* top;
};

class Queue
    {
public:
    Queue(void);
    ~Queue(void);
    void Enqueue(int i, int priority = 0);
    int Dequeue(void);
    protected:
    Node* back;
    Node* front;
private:
    virtual Node* NodeDequeue(void);
    };

所以这些是我们上过的课程,我正在努力让球在某种意义上滚动。去年我用指针和模板做了一个简单的堆栈,但我无法弄清楚从哪里开始使用 get 和 set 函数的附加功能。我只被允许使用 iostream 作为提醒。

标签: classstackqueue

解决方案


推荐阅读