(10-08-2009, 08:19 AM)TheDoctor Wrote: When I use your code, it stills gives me an error :S
Error : In member function ‘std:tring User::Check(std:
tring)’:
AND
warning: control reaches end of non-void function
???
It works though, thanks. Kind of weird output when I enter the wrong name, but still
I don't get that error, but you can avoid the error by changing string Check() to int Check() and make it return true or false
Code:
int Check(string x)
{
string com = Name;
if ( com == x)
{
return 1;
}else{
return 0;
}
}
Then you call Check within an if condition
Code:
if(user->Check(x))
{
cout << "You made it. Congratz" <<endl;
}
If the function returns true you output the message
http://www.ibm.com Wrote:This warning is similar to the warning described in Return with no value. If control reaches the end of a function and no return is encountered, GCC assumes a return with no return value. However, for this, the function requires a return value. At the end of the function, add a return statement that returns a suitable return value, even if control never reaches there.