Class 我正在努力开始使用堆栈和队列,想知道是否有人可以基于这些类提供帮助? #包括; 使用名称空间std; 类节点 { 公众: 节点(int值,节点*nextptr=NULL,节点*prevptr=NULL,int currentpriority=0); int getVal(void); 节点*getNext(void); 节点*getPrev(void); void setVal(int值); void setPrev(节点*prevptr); void setNext(节点*nextptr); int getPriority(void); 无效设置优先级(int优先级); 私人: 节点*下一步; 节点*prev; int优先级; int值; }; 类堆栈 { 公众: 栈(空); ~Stack(void); 无效推送(int值); Node*NodePop(void); int Pop(无效); 私人: 节点*顶部; }; 类队列 { 公众: 队列(无效); ~队列(无效); 无效排队(int i,int优先级=0); int退出队列(void); 受保护的: 节点*返回; 节点*前端; 私人: 虚拟节点*节点队列(无效); };
这就是我们所上的课程,我正在努力让球在某种意义上滚起来。去年我用指针和模板做了一个简单的堆栈,但我很难找到从get和set函数的附加功能开始的地方。我只允许使用iostream作为提示Class 我正在努力开始使用堆栈和队列,想知道是否有人可以基于这些类提供帮助? #包括; 使用名称空间std; 类节点 { 公众: 节点(int值,节点*nextptr=NULL,节点*prevptr=NULL,int currentpriority=0); int getVal(void); 节点*getNext(void); 节点*getPrev(void); void setVal(int值); void setPrev(节点*prevptr); void setNext(节点*nextptr); int getPriority(void); 无效设置优先级(int优先级); 私人: 节点*下一步; 节点*prev; int优先级; int值; }; 类堆栈 { 公众: 栈(空); ~Stack(void); 无效推送(int值); Node*NodePop(void); int Pop(无效); 私人: 节点*顶部; }; 类队列 { 公众: 队列(无效); ~队列(无效); 无效排队(int i,int优先级=0); int退出队列(void); 受保护的: 节点*返回; 节点*前端; 私人: 虚拟节点*节点队列(无效); };,class,stack,queue,Class,Stack,Queue,这就是我们所上的课程,我正在努力让球在某种意义上滚起来。去年我用指针和模板做了一个简单的堆栈,但我很难找到从get和set函数的附加功能开始的地方。我只允许使用iostream作为提示 #include <iostream>; using namespace std; class Node { public: Node(int value, Node* nextptr = NULL, Node* prevptr = NULL, int currentpriorit
#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);
};