I'm doing an example from Head First Object Oriented Analysis and Design, but I'm coding in C++ and I don't know how to write the equivalent of "return null" from java.
Guitar getGuitar(string serialNumber)
{
for (vector<Guitar*>::iterator it = guitars.begin(); it != guitars.end(); ++it)
{
if ((*it)->getSerialNumber() == serialNumber)
{
return **it;
}
}
//return null ( java); What should return here ?!
}
Guitar*,return **it;does actually return an object of typeGuitar. You are trying to mix both which is not correct.std::find.