コンパイル時に次のエラーが発生します。
エラー C2270: 'busco': 修飾子は非メンバー関数では許可されていません
理由は理解できたと思いますが、修正方法がわかりませんconst
。取り出すと C2662 エラーが発生します。
コードは次のとおりです。
template <class T>
class ABBImp: public ABB<T> {
public:
const T& Recuperar(const T &e) const ;
private:
NodoABB<T> * busco(NodoABB<T> * arbol,T &e) const;
protected:
NodoABB<T>* arbol;
};
template <class T>
//If I take this const out I get the other error I talked about
NodoABB<T>* busco(NodoABB<T> * arbol,T &e)const{
if(a!=NULL){
if(arbol->dato==e)
return arbol;
else if (arbol->dato<e)
return busco(arbol->der,e);
else
return busco(arbol->izq,e);
}else{
return NULL;
}
}
template <class T>
const T& ABBImp<T>::Recuperar(const T &e) const{
NodoABB<T> * aux=busco(arbol,e);
return aux->dato;
}
ありがとう!