【发布时间】:2020-10-27 19:25:22
【问题描述】:
我正在创建堆栈的链表实现。在Node 结构中,我有数据成员data 和next。我的问题是,为什么数据成员next 需要声明为struct Node * next 而不仅仅是Node *next?
template <class T>
class Stack{
private:
struct Node{
T data;
struct Node *next; //This is what the question is in reference to
};
Node *front;
Node *end;
public:
};
【问题讨论】:
-
如果这是 C,您将需要
struct,但不是。我猜你实际上没有尝试过。
标签: c++ struct linked-list queue declaration