次のようなリンクリスト構造があります。
template<class T>
class LinkedList {
private:
template<class U>
struct Node {
U data;
Node<U> *link;
};
Node<T> *head;
};
私が理想的にやりたいことは、次のように、内部クラスの定義を の宣言とマージすることですhead
。
// Is something like this possible?
template<class U>
struct Node {
U data;
Node<U> *link;
} head; // Put head right here somehow, while also specifying the type parameter.
構造を作成することの要点Node<U>
は を定義することだからhead
です。この2つを結びつけることは可能ですか?