0
template <class Type>
class Node
{
public:
Node()
{
}
Node (Type x, Node* nd)
{
data = x;
next = nd;
}
Node (Type x)
{
data = x;
next = NULL;
}
~Node (void)
{
}
Node (const Node* & nd)
{
data = nd->data;
next = nd->next;
}
Node & Node::operator = (const Node* & nd)
{
data = nd->data;
next = nd->next;
}
T data;
Node* next;
};
難道我更換每一個節點*與轉換爲模板類(節點)
Node*<Type>
我試圖取代它,並試圖運行像
Node* temp = myq.head;
但它說類參數列表模板「節點」丟失。當我需要節點類本身作爲它的一部分時,我不太確定如何使用模板
什麼'myq.head'?它是如何定義的? – billz
my.qhead只是另一個Node對象,技術上它應該是。但現在它真的不是因爲myq.head不會被首先定義的 – user2472706
我們在前幾天有一個類似的問題,請看這裏:http://stackoverflow.com/a/19034786/1529139 – 56ka