Just wondered what you guys do when you need a method that returns a
const reference to some data based upon some value.
something like this:
const CData& MyClass::GetDataWithValue(int iValue)const
{
for (int idx=0; idx<m_iNumRecords; ++idx)
{
if (m_Records[idx].GetValue() == iValue)
{
return m_Records[idx];
}
}
}
Most compilers will give a warning here. Something like "Warning: Not
all paths return a value"
This is fair enough but occasionally i know that this method will
*always* work correctly because there is no possible way iValue could
be anything else but valid. I'm certain this sort of thing crops up
for other programmers also. So my Q is: What do you do about it? (I
just ignore the warning at the moment but it irritates me!)