and i get error with
error C2451: conditional expression of type 'std::basic_string<_Elem,_Traits,_Ax>' is illegal

void system1::search() {
    cout<<"Enter ID to be Searched: ";
    int data_search;
    cin>>data_search;
     nodetype *current = head;
    while(current != NULL) {
        if(current->ID == data_search) {
                cout<<"\n----Linked List Linear Search Result----\n";
                cout<<"ID: "<< current->ID <<endl;
                cout<<"Name: "<< current->NAME <<endl;
                break;
        }
        else
            current = current->link;
    }


}

Recommended Answers

All 2 Replies

I would suspect, that if ID is a string, that this,if(current->ID == data_search), is trying to compare an int and a string, which are 2 different types. You'll have to change/convert one or the other to the other type.

data_search is an integer. But is current->ID also an integer?
It seems that current->ID is a string. Probably you can use std::stoi(current->ID) to solve the problem.

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.