class - 我正在努力开始使用堆栈和队列,并且想知道是否有人可以根据这些类提供帮助?
问题描述
#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 作为提醒。
解决方案
推荐阅读
- ruby-on-rails - 如何将设计数据传递给 React 组件?
- java - 如果在“pluginManagement”中添加“plugin”标签,则在 java 代码中将 maven 配置标签值设置为 null(看下面的代码)
- php - 如何将数组 JSON 解析为 PHP 对象?
- c - 一些简单的逻辑问题并打印 C++ HouseWindowsLab
- r - 根据 R 中的前 3 个字符进行分类
- mysql - 通过 cmd 将大型数据库导入 mysqlAdmin 时出错
- deep-learning - 使用 pytorch 训练神经网络时损失的周期性模式
- .net - 使用 LoggerFactory 登录 Application Insights for .NET Core 2.1 控制台应用程序
- popup - 关闭对话框后Appium找不到任何元素
- javascript - Javascript为不同的div加载具有特定功能的php文件