P
puzzlecracker
The code fails to compile: why?
can't figure out how to fix it....
std::map<string, const Foo*> m;
//assign to pFoo if it is in the map
bool TryToAssign(int i, const Foo* & pFoo) /*fails to compile*/
{
std::map<int , const Foo* >::const_iterator iter=m.find(i);
if(iter!=m.end())
pFoo=iter->second;
else
return false;
return true;
}
void Test()
{
const Foo* f;
if(TryToAssign(6, f))
cout<<"SUCCESS... õòá\n";
}
can't figure out how to fix it....
std::map<string, const Foo*> m;
//assign to pFoo if it is in the map
bool TryToAssign(int i, const Foo* & pFoo) /*fails to compile*/
{
std::map<int , const Foo* >::const_iterator iter=m.find(i);
if(iter!=m.end())
pFoo=iter->second;
else
return false;
return true;
}
void Test()
{
const Foo* f;
if(TryToAssign(6, f))
cout<<"SUCCESS... õòá\n";
}