1

テンプレートクラス threadBinaryTreeと関数を宣言しました

void threadBinaryTree<T>::inThread
     (threadBinaryTreeNode<T>*root,threadBinaryTreeNode<T>*& pre)

しかし、エラーに準拠しています:

no matching function for call to ‘threadBinaryTree<char>::inThread
      (threadBinaryTreeNode<char>*, NULL)’|

preNULL として初期化する必要があります。どうすればよいですか?

4

3 に答える 3

4

2 番目の引数は、ある種のポインターへの非 const 左辺値参照を取りますが、右辺値 (NULL) を渡しています。右辺値を非 const 左辺値参照にバインドすることはできません。左辺値を渡す必要があります。

threadBinaryTreeNode<T>* p = NULL;
x.inThread( somePtr, p );
于 2013-10-13T08:47:24.783 に答える
1

2 番目の引数はthreadBinaryTreeNode<T>*& pre、渡せないようNULLになっています。

threadBinaryTreeNode<T> *empty = 0; // Pass empty to the method instead of NULL

また、よりも0andを使用することをお勧めします。nullptrNULL

于 2013-10-13T08:47:44.113 に答える
0

関数の 2 番目の引数は非 const 参照であるため、次のような変数を指定する必要があります。

threadBinaryTreeNode<char>* ptr = NULL;
inThread(..., ptr);
于 2013-10-13T08:47:47.000 に答える