C++ - Compiling error on a tree homework : error: expected constructor, destructor, or type conversion before ‘*’ token

StackOverflow https://stackoverflow.com/questions/4200904

  •  25-09-2019
  •  | 
  •  

Question

I'm currently trying to do a homework, and I'm trying to get my things to compile at first (class headers in the .h file, and the empty definitions in the .inl file (I'm using the typename template)).

I'm getting this error :

error: expected constructor, destructor, or type conversion before ‘*’ token

Here's my .h file : http://ideone.com/dm3Bp

Here's my .inl file: http://ideone.com/5FBep

I'm trying to make a Node (called Noeud, in these files) at the end of the .inl file. apparently, I can't take a value from array of type E data...

The error is just before the definition of the method:

Noeud * Arbre<E>::_auxPereSym(E *tabS, int debut, int fin, E **ptr, int &card) throw (std::bad_alloc)

I've read in other threads that the return type should be Arbre< E >::Noeud Because Noeud is a nested structure of my class Arbre... But unfortunately, I can't change the header file...

Any thoughts?

Thanks for you time and help.

Note: Let me know if a translation is needed for anything, this is a french homework.

Was it helpful?

Solution

Try to qualify as so while defining in .inl file (and not the header file as per your concern).

The return type needs to be looked up in the proper scope appropriately.

BRAIN COMPILED CODE AHEAD

template<typename E>
typename Arbre<E>::Noeud * Arbre<E>::_auxPereSym(E *tabS, int debut, int fin, E **ptr, int &card) throw (std::bad_alloc)

EDIT2:

change return statement in the member function as so:

return new typename Arbre<E>::Noeud(tabS[0]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top