I have been doing some research about this and have found a few similar questions on stackoverflow talking about the visibility of types, but this doesn’t seem to be exactly the same problem (or at least that’s what I think after some hours working on it).
Let’s focus:
The problem
C++ compiler reports “abc.cpp:132: error: expected constructor, destructor, or type conversion before ‘*’ token”
The code where the problem is reported
template <class C, class I> ABC<C, I>::Node * ABC<C, I>::buscaTreuIRetornaMinim(Node **node) {
if (*node == NULL) return NULL;
if ((*node)->fesq != NULL) return buscaTreuIRetornaMinim(&(*node)->fesq);
Node *q = *node;
*node = *node->fdre;
return q;
}
The problem is reported on the first line, the function header. So far, I understand the problem is when specifying ‘Node *’ but it’s already fully qualified so I don’t see where’s the problem.
The rest of the class definition
class ABC {
public:
ABC(void) : arrel(NULL), numelements(0), altura(0) { }
void inserir(C pclau, I pinfo);
void inordre(void);
I consultar(C pclau);
C minim(void);
C maxim(void);
void esborrar(C pclau);
private:
class Node {
public:
C clau;
I info;
Node *fesq;
Node *fdre;
Node(C pclau, I pinfo, Node *pfesq = NULL, Node *pfdre = NULL) : clau(pclau), info(pinfo), fesq(pfesq), fdre(pfdre) { }
};
Node *arrel;
Node *actual;
int numelements;
int altura;
void inserir(C pclau, I pinfo, Node **node);
void inordre(Node **node);
I consultar(C pclau, Node **node);
C minim(Node **node);
C maxim(Node **node);
void esborrar(C pclau, Node **node);
Node * buscaTreuIRetornaMinim(Node **node);
};
On the other hand, I can ensure the rest of the functions are fully functional. That’s the only problem I have dealt with so far.
Any tip will be greatly appreciated. Thanks in advance for your time.
A qualified type name that includes template parameters must be prefixed with the keyword
typename:typename ABC<C, I>::Node *You can read more about about the necessity of this
typenamekeyword here.