its about Data Structure

(in doubly link List )

this is my function
bool search( T item)
{
nodetype <T> *cur;
bool found;
cur=first;
while(cur!=NULL && !found)
{
if((cur->info).name==item)
return true;
else
cur=cur->next;
}
return found;
}

and this is the error :

error C2664: 'search' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'struct Book'
        No constructor could take the source type, or constructor overload resolution was ambiguous

this the call from main :
case 3:
cout<<"Please Enter person's name to search :";
cin>>name2;
cout<<"\n";
found=L1.search(name2);
if(found==false)
cout<<"Not found\n";
else
L1.display(name2);
break;

Your search function takes an item of type T (which is a structure named Book by the looks of it) and you are trying to pass a string variable to it.

Your search function takes an item of type T (which is a structure named Book by the looks of it) and you are trying to pass a string variable to it.

OK ,thanks

and how i can solve this error ;
this is the struct :

struct Book{
address AD;
string name;
long phone;
};


OK ,thanks

and how i can solve this error ;
this is the struct :

struct Book{
address AD;
string name;
long phone;
};

Can you give information about

struct Book{
[U]address AD;[/U]
...
 
};

what kind of data type address is?

Can you give information about

struct Book{
[U]address AD;[/U]
...
 
};

what kind of data type address is?

address is onother struct :

struct address{
long roadNo;
string roadname;
long homeNo;
};

address is onother struct :

struct address{
long roadNo;
string roadname;
long homeNo;
};

may be you try to use address structure before you define it.

as the compiler goes one way : from up to down, no turn back.
so I think you first defined the the Book struct, then defined the address struct.
try moving the address struct before the Book struct.

But, if there is any other error causing that issue, I don't have anything to say

may be you try to use address structure before you define it.

as the compiler goes one way : from up to down, no turn back.
so I think you first defined the the Book struct, then defined the address struct.
try moving the address struct before the Book struct.

But, if there is any other error causing that issue, I don't have anything to say

they are in order,

addrss first then Book

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.