?
Solved

C++  cannot convert parameter 1 : Function Problem...  (urgent )

Posted on 2003-03-10
3
Medium Priority
?
269 Views
Last Modified: 2008-02-01
Hi
here is my code :

in my main() :

string TypeWord ;
 int plen ;
 cin >> TypeWord;
 plen = TypeWord.length();
 cout << plen;

if (VerifyWord(TypeWord,plen)) // here is my mistake
{
cout << TypeWord << " is in tree ";
}
else {
cout << TypeWord << "is not in tree." ;
}
               
here is my function VerifyWord :

bool VerifyWord(const char * word, int len)
{
  int plen;
  Dictio * n = root -> follow(word,len,plen);
  return (plen == len && n -> IsFullWord());
}          
     
here is my error :
'VerifyWord' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'

i know i wont convert cause its not the same but i cant make it work
i type a word and i check if its in my tree.
how can i make my CIN<< TypeWord ... word

need an answer
0
Comment
Question by:Italbro2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 120 total points
ID: 8107476
Either change VerifyWord to look like:
bool VerifyWord(const std::string &word, int len)

or change the call to
if(VerifyWord(TypeWord.c_str(), plen))// c_str is the const char * conversion function
0
 

Author Comment

by:Italbro2
ID: 8108135
thk you
works good
0
 
LVL 8

Expert Comment

by:mnashadka
ID: 8108396
I'm glad I could help.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question