以私有方式声明的节点
Nodes declared in private
我已经很久没有用C++编程了,真的很生疏。请帮帮我?我的任务是开发一个可逆的单链列表,但节点必须私下声明。我如何访问它们以从堆栈中推/弹出。还是我做错了?
#include <iostream>
using namespace std;
class ReversibleStack
{
public:
void push(int item);
int pop();
bool IsEmpty();
void Reverse();
private:
// let's build our singly linked list in private
typedef struct node
{
int first; //the first node
node *next; //pointer to the next node available
}node;
};
#include "ReversibleStack.h"
#include <iostream>
using namespace std;
//This is the Push function that pushes an item onto the stack
void Push(int Item)
{
node* current = first; // sets current pointer to first
node* new_item = Item; // sets previous pointer to NULL
node* next = current->next; // next item in stack
}
这几乎是一个语法问题。您定义的方法如下:
void ReversibleStack::Push(int Item)
{
// ...
}
相关文章:
- .cpp和.h文件中的模板专用化声明
- 反向给定链表中的K节点
- 如果我只是不访问queue_front节点的子节点,而是将它们推到队列中呢?还是BFS吗
- 未在作用域中声明unordered_map
- C++避免重复声明的语法是什么
- 如何确保C++函数在定义之前声明(如override关键字)
- 错误:未在此范围内声明'reverse'
- 奇怪的(对我来说)返回声明 - 在谷歌上找不到任何关于它的信息
- 为什么在定义函数之前先声明它
- 链表中头/第一个节点的声明
- 使用括号会在声明新节点时会产生错误
- 在声明节点创建链接列表时,为什么静态内存分配不起作用
- 存储在clang ast中的声明节点
- 声明新节点但不等于 NULL
- 节点数组声明
- 在C++中声明节点时,何时需要使用新运算符
- 以私有方式声明的节点
- List Traversal w/temp指针-在声明指针时分配指针引用的节点空间有危险
- 为什么将链表的第一个节点声明为指针
- 列表节点指针"未在此范围内声明"?