throw an exception or return NULL object in C++?
<p>I have this method to find an object in a list in C++.</p>

<pre><code>Step Config::getStep(string stepName)
{
    for(int i=0; i&lt;_NoSteps; i++)
    {
        if(_Steps[i].getStepNameStr().compare(stepName)==0)
        {
            return _Steps[i];
        }
    }

    cout &lt;&lt; "ERROR. No processing step found for: " &lt;&lt; stepName &lt;&lt; endl;
    // case 1: throw exception
    // case 2: return null
}
</code></pre>

<p>I got an error while compiling: 'not all control paths return a value' as I set it 'treated warning as error'</p>

<p>I would like to know how to:</p>

<ol>
<li><p>how to throw a custom exception if there is no object found</p></li>
<li><p>how to return a NULL object in C# like:  return null</p></li>
</ol>

<p>Thanks in advance.</p>
