can function return 0 as reference
- by helloWorld
I have this snippet of the code
Account& Company::findAccount(int id){
for(list<Account>::const_iterator i = listOfAccounts.begin(); i != listOfAccounts.end(); ++i){
if(i->nID == id){
return *i;
}
}
return 0;
}
Is this right way to return 0 if I didn't find appropriate account?
cause I receive an error:
no match for 'operator!' in '!((Company*)this)->Company::findAccount(id)'
I use it this way:
if(!(findAccount(id))){
throw "hey";
}
thanks in advance