Menu

templating a class - what the hell's wrong?

2002-11-08
2012-09-26
  • Nobody/Anonymous

    I am attempting to template my previously successful class alphatree.

    After much cutting and pasting (placing the previously separate definitions within the header file) and attempting to track down errors, I now
    have the following error:

    102 alphatree.h
    end of file read inside definition

    which refers to this definition:

    void erase(string& thisword) // line 102 immediately below
                       {   
                              iterator tn = find(thisword);
                              if (tn == 0)
                              {
                                 return;
                              }
          
                              for (int i = 0; i< 26; i++)
                              {
                                  if (tn->branches[i] != 0)
                              {
                              tn->flag = 0;
                              --nodecount;
                              return;
                      
                              int charpos = tn->first.length()-1;
          
                              while (charpos != -1)
                              {
                                    Tnode<T>* parent = tn->parent;
                                    parent->branches[tn->first[charpos]-97]= 0;
                  
                                    if (this->size() == 1 && tn->flag != 0)
                                    {
                                       firstnode = 0;
                                       lastnode = 0;
                                       endroot = 0;
                                    }
                
                                    if (tn == firstnode)
                                    {
                                       iterator temp_it = firstnode;
                                       ++temp_it;
                                       firstnode = temp_it.it;
                                    }
                                    if (tn == lastnode)
                                    {
                                       iterator temp_it = lastnode;
                                       ++temp_it;
                                       lastnode = temp_it.it;
                                    }
                
                                    if (tn->flag != 0)
                                    {
                                       --nodecount;
                                    }
                                    delete tn.it;
                
                                    tn = parent;
                
                                    if (tn->flag != 0)
                                    {
                                       return;
                                    }
                                    for (int i=0; i< 26; i++)
                                    {
                                        if (tn->branches[i] != 0)
                                        {
                                           return;
                                        }
                                    }
                                    --charpos;
                               }
                               return;
                    } 

    Does anyone have any idea what is causing this?

    Thanks

    Derek

     
    • Nobody/Anonymous

      Further to my original post, I am also getting a: parse error at end on input in MAIN.

      Derek

       
    • Nobody/Anonymous

      This is just a hunch, but perhaps the actual error is somewhere before the given line... missing semi-colon or something like that.

       
    • Nobody/Anonymous

      In case anyone is interested, just like to say I got the program running.

      Still have no idea what the original problem was; junked the whole thing and started over. Took a more step by step approach and it worked!.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.