【发布时间】:2014-06-01 01:37:01
【问题描述】:
编译时出现此错误:
错误 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;
}
谢谢!
【问题讨论】:
标签: c++ visual-studio-2012 compiler-errors modifiers non-member-functions