こんにちは、これはコードです:クラス "エントリ" でC++でクラスを再帰的に呼び出す方法は?
template <class T> class FibonacciHeap{
public:
class Entry{
public:
// Returns the element represented by this heap entry.
T getValue(){
return mElem;
}
// Sets the element associated with this heap entry.
void setValue(T value){
mElem = value;
}
// Returns the priority of this element.
double getPriority(){
return mPriority;
}
private:
int mDegree = 0; // Number of children
bool mIsMarked = false; // Whether the node is marked
Entry mNext; // Next element in the list
Entry mPrev; // Previous element in the list
Entry mChild; // Child node, if any
Entry mParent; // Parent node, if any
T mElem; // Element being stored here
double mPriority; // Its priority
//Constructs a new Entry that holds the given element with the indicated priority.
Entry(T elem, double priority){
mNext = mPrev = this;
mElem = elem;
mPriority = priority;
}
};
...
私は再帰的にエントリを呼びたいので、私は使用することができます。
First_entry.mPrev.mNext
私は、これはJavaで動作します知っているが、IこれをC++でコンパイルすると、次のようになります。
error: 'FibonacciHeap<T>::Entry::mNext' has incomplete type
誰でもこれを修正する方法を知っているのですか?
ちょうどメモ:これは再帰ではありません。 – m0skit0
'Entry mNext;'、 'Entry mPrev;'、などあなたはここに何かがありません。コンパイラを聞く。 – DimChtz
C++では、ほとんどのリストはノードまたは 'Entry'へのポインタを使います。 Javaにはポインタがありません。 –