expected unqualified-id before ""

Im getting the error expected unqualified-id before "delete" for a program that im working on and i have no ieda what to do for it.any help would be appreciated

header:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
template<class itemtype>
class llist
{
      friend std::ostream& operator<<(std::ostream & , llist<itemtype> &);
      private:     
      struct nodetype
      {
      itemtype item;
      nodetype *next;
      };
      nodetype *first, *last;
      public:
             llist();
             void firstinsert(itemtype);
             void frontinsert(itemtype);
             void endinsert(itemtype);
             void inorderinsert(itemtype);
             bool search(itemtype);
             bool delete (itemtype); -problem line 
             bool listempty();
             itemtype firstitem();
             itemtype lastitem();
             ~llist();
};
#endif 


i just cut down my implementation code to include the problem function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
template <class itemtype>
bool llist<itemtype>::delete (itemtype x)-problem line
{
     nodetype *cur, *prev;
     prev=null;
     cur=first;
      while ((cur!=0)&&(x!=cur->item))
     { 
            prev=cur;
            cur=cur->next;
            if(cur==0)
                return 0;
            else
            {
                delnode=cur;
                if(prev==0)
                {   
                    first=first->next;
                }
                else
                {
                prev->next=cur->next;
                if (cur==last)
                   last=prev;
                }
                delete delnode;
                return 1;
            }
     }
}


I also have the error 104 expected `;' before "delete" for the same line too.
thanks for the help.
delete is a C++ keyword. It will cause problems if you try to use it as an identifier name.

( You will notice that the syntax highlighting shows it in the keyword colo(u)r)
alright,so how can i fix the code to get rid of those errors?

I changed the line to
delete () and im still getting the same errors.


Sorry to be a pain about this but i could use the help.
delete is an overloadable operator but it has to have void return type and get a void* parameter
so i have to change bool to void for both? can i still use the code that i already had for the function?
Yes, also remove the return lines
i did both and im still getting the errors.

header:
void delete (itemtype);


implementation:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
template <class itemtype>
void llist<itemtype>::delete (itemtype x)
{
     nodetype *cur, *prev;
     prev=0;
     cur=first;
      while ((cur!=0)&&(x!=cur->item))
     { 
            prev=cur;
            cur=cur->next;
            if(cur==0)
           (delnode !=cur)
            else
            {
                delnode=cur;
                if(prev==0)
                {   
                    first=first->next;
                }
                else
                {
                prev->next=cur->next;
                if (cur==last)
                   last=prev;
                }
                delete delnode;
            }
     }
}
delete is a keyword in C++. Rename your delete function to something else.
thanks i fixed it
Topic archived. No new replies allowed.