-2

I have a problem with "instantied from here".

template <typename E>
class tree
{
public:
    tree(){root=0;}
    void addAVL( const E &data) throw(bad_alloc);
private:
    class Node
    {
    public:

        E data;             
        Noeud * left;       
        Noeud * right;      
        int high;       
        std::string adHier; 

        Noeud( const E&d ): data( d right( 0 ),left( 0 ),high(0), adHier("") { }
    };
    Node * root;
};

#include "AVL.inl"

/*-------------------------
*in my inl
*/
template <typename E>
void tree<E>::addAVL( const E &data) throw(bad_alloc)
{
    // if the trre is empty
    if ( root == 0 )
    {
        root = new Node(data);  // HERE my error when in a cpp I call addAVL
    }
}

My error is:

../AVL.inl:98:   instantiated from ‘void AVL_Lab10::tree<E>::addAVL(const E&) [with E = int]’
../TestingAVL.cpp:30:   instantiated from here
Roots
  • 63
  • 6

2 Answers2

3
Noeud * left;
Noeud * right;
Noeud( const E&d ): ...

I guess that should be Node not Noeud? Does it fix your errors if you correct those typos?

Xeo
  • 129,499
  • 52
  • 291
  • 397
  • That aside, Node is also a private inner class. – phooji Apr 14 '11 at 03:09
  • @phooji: Nothing wrong with that, as it's a privat inner class of `tree`, which should be the only class using it. – Xeo Apr 14 '11 at 03:18
  • Ah I scrolled down to see the instantiation is a tree member :) Still wouldn't be my choice for a design though -- hard(er) to adjust allocation later on this way. – phooji Apr 14 '11 at 03:31
  • @phooji: I'm curious; what do you mean by "hard(er) to adjust allocation"? The only difference between a nested class and a regular one is visibility. Did you mean the ability to specify some kind of allocator policy for `tree`, like in STL containers? – Emile Cormier Apr 14 '11 at 03:39
  • @Emile Cormier: That is what I was referring to; it also applies to homebrewn datastructures if you want to switch to a pool allocator later on. – phooji Apr 14 '11 at 03:59
0

finaly I not found the prob, but i can build... my teach say me that he have the samme prob with gcc compilator in eclipse. It's very curious because each time i add some code in my .inl and i save. The error icon display ....

Thank you for your help ! :D

Roots
  • 63
  • 6