hi
please solve my problem i am getting linking error in following program. i am using devc++ for copilation

linking errors:
C:\Users\shiv\AppData\Local\Temp\ccaMbaaa.o(.text+0x286) In function `ZN4list7delnodeEi':
C:\Users\shiv\AppData\Local\Temp\ccaMbaaa.o(.text+0x286) In function `ZN4list7delnodeEi':
[Linker error] undefined reference to `list::search(int, Node**, Node**)'
C:\Users\shiv\AppData\Local\Temp\ccaMbaaa.o(.text+0x62c) ld returned 1 exit status

#include<iostream>
#include<conio.h>
#include<string.h>
using namespace std;
class Node
{
     public:
     int roll;
     char name[50];
     Node * next;
};
class list
{
      Node *start;
      public:
      list();  //constructor for initialisation 
      int addnode(int x);   //function for addinng nodes in the class
      bool delnode(int y); ///for deletion
      bool search(int roll,Node **current,Node **privious); //for searching
      bool listempty();    //function to check weather stack is empty or 
      int traverse();

};
list:: list()
{
       start=NULL;
}
int list:: addnode(int r)
{
    char name[50];
    cout<<"enter roll no \n";
    cin>>r;
    cout<<"enter name\n";
    gets(name);
    cin.get();
    Node *newnode=new Node;
    newnode->roll=r;
    strcpy(newnode->name,name); // could not copy directoly like newnode->name=n
    if((start==NULL)||(r<start->roll)) //roll to be inserted is first one
    {
        if((start!=NULL)&&(r==start->roll))
        {
                                              cout<<"duplicacy not allowed";
                                              return 0;
        }
    newnode->next=start;
    start=newnode;
    return 0;
    }
 //code for inserting in between node,it would also work for begning
    Node *previous,*current;
    previous=current=start;
    while((current!=NULL)&&(r>current->roll))
    {
                  if(r==current->roll)
                  {
                                      cout<<"duplicacy not allowed";
                  }                           
                  previous=current;
                  current=current->next;
    }
    newnode->next=current;
    previous->next=newnode;
    
}
//delete function;
    bool list :: delnode(int element)
    {
        Node *current,*previous;
        if(search(element,&current,&previous))
        cout<<"element is not present in the list";
        previous->next=current->next;
        if(current ==start)
        start=start->next;
        delete current;
        return true;
        
    }

//search function
   bool search(int roll,Node **current,Node **previous)
    {
        *previous=*current=NULL;
        while((*current!=NULL)&&(roll!=(*current)->roll))
        {
                                                      *previous=*current;
                                                      *current=(*current)->next;
        }
        return(*current!=NULL);
    }
bool list :: listempty() // to check if list is empty
{
    if(start=NULL)
     return true;
    else
     return false;
}
int list :: traverse()
{
    if(listempty())
    {
                   cout<<"list is empty no need to travrse add elements to list\n";
    }
    else
    {
        cout<<"the records in the lists are:\n";
        Node * current;
        for(current=start;current!=NULL;current=current->next)
        {
                                                              cout<<current->roll<<"s name is "<<current->name<<"\n";
        }
    }
    
    
}
    
 main()
{
    list l;
    int rollno;
    char ch;
    while(1)
    {
            cout<<endl<<"********menu*******";
            cout<<"1.add a record to the list\n";
            cout<<"2.delete a record from list\n";
            cout<<"3.view all the records in list\n";
            cout<<"4.search a roll no in the list\n";
            cout<<"5.exit\n";
            cout<<"\n enter your choice(1-5)";
            cin>>ch;
            switch(ch)
            {
                      case '1':
                      {
                           l.addnode(rollno);
                      }break;
                      case '2':
                      {
                           if(l.listempty())
                           {
                                            cout<<"list is empty no element could be delted add elements in the list";
                                            break;
                           }
                           cout<<"enter the roll no of the student whose record is to be deleted\n";
                           cin>>rollno;
                           if(l.delnode(rollno)==false)
                             cout<<"no record found for this roll no\n";
                           else
                           cout<<"record with roll no"<<rollno<<"deleted\n";
                      }
                      break;
                      
                      case '3':
                      {
                           l.traverse();
                      }
                      break;
                      case '4':
                      {
                           if(l.listempty())
                           {
                           cout<<"list is empty";
                           break;
                           }
                           Node *previous,*current;
                           cout<<"\n enter the roll no of student whose record is to be searched";
                           cin>>rollno;
                           if((l.search(rollno, &previous, &current)==false)) //FALSE
                           cout<<"record not found<!>\n";
                           else
                           {
                               cout<<"record found!\n";
                               cout<<"\nroll no:"<<current->roll;
                               cout<<"\n\nName:"<<current->name;
                           }
                      }break;
                      case '5':
                           {
                               exit(0);
                           }break;
                           default:
                                   {
                                       cout<<"invalid option";
                                   }break;
                      }
            }
    
 
    getch();
//    return 0;
}

If think you should upgrade your compiler, its passing back mangled names in its error message.

This, on line 81

bool search(int roll,Node **current,Node **previous)

Should be

bool list::search(int roll,Node **current,Node **previous)

There is no upgrade to that compiler -- it has been dead and buried for quite some time now.

I think using mangled names is common to all linkers -- all Microsoft compilers do that too. It's beyond the scope of a linker to know the unmangled name. The mangled name is actually more useful information because it tells you exactly which of all function overloads caused the problem.

than budyy...
my compiler is already upgraded ..
only problem was with syntex as you pointed out.
now its working fine

There is no upgrade to that compiler -- it has been dead and buried for quite some time now.

I think using mangled names is common to all linkers -- all Microsoft compilers do that too. It's beyond the scope of a linker to know the unmangled name. The mangled name is actually more useful information because it tells you exactly which of all function overloads caused the problem.

I run a current version of GCC and its linker passes back non-mangled names.

i am using devc++ code is running..
actually i am not able to install GCC could you let me know how cold i install GCC since info given on their site is not enough

i am using devc++ code is running..
actually i am not able to install GCC could you let me know how cold i install GCC since info given on their site is not enough

I'll assume your running Windows.

Download Code::Blocks or QT Creator and you'll get a current version of GCC with either or you could try Window's Visual C++ express.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.