C++;类指针,即节点* 在C++中,我们为什么要在不指定int、双等的情况下编写节点指针类节点,也可以在主节点中声明新的节点指针,而不使用任何节点类声明。 class Node { public: int data; Node* next; };
如果它是任何不同类型的指针,那么它在代码中被称为什么?C++;类指针,即节点* 在C++中,我们为什么要在不指定int、双等的情况下编写节点指针类节点,也可以在主节点中声明新的节点指针,而不使用任何节点类声明。 class Node { public: int data; Node* next; };,c++,class,oop,pointers,linked-list,C++,Class,Oop,Pointers,Linked List,如果它是任何不同类型的指针,那么它在代码中被称为什么? class Node { public: int data; Node* next; }; template <typename T> class Node { public: T data; Node<T>* next; }; 只有一种节点,它有一个int用于数据。这就是为什么不需要编写节点或节点。但是你可以改变你的代码 class Node { publi
class Node {
public:
int data;
Node* next;
};
template <typename T>
class Node {
public:
T data;
Node<T>* next;
};
只有一种节点,它有一个int
用于数据。这就是为什么不需要编写节点
或节点
。但是你可以改变你的代码
class Node {
public:
int data;
Node* next;
};
template <typename T>
class Node {
public:
T data;
Node<T>* next;
};
我怀疑你没有一本好书。在C++中,链表是名为<代码> STD::列表< > /COD>的模板,并且不必麻烦节点。注意:<代码>节点*和<代码>节点*<代码>不是同一件事。问题是“为什么
Node
被视为一种类型”?不管怎样,如果不将节点包含在使用它的任何其他位置,则不能使用节点