title: How to properly return null/empty object in C++?
body: <p>I am a Java developer trying to solve a simple C++ task. In Java, if I want to return an empty/null object, to indicate that object is not found I just return null. Example:</p>
  <pre class="lang-java prettyprint-override"><code>Person getGetByName(String name) {
  
      for (int i = 0; i &lt; 10; i++) {
          if (people[i].name == name) {
              return people[i];
          }
      }
      return null;
  }
  </code></pre>
  <p>later in code I can do</p>
  <pre class="lang-java prettyprint-override"><code>Person p = getByName(&quot;Sam&quot;);
  
  if (p == null) { ...
  }
  </code></pre>
  <p>In C++ I have the following method</p>
  <p>It seems that if I declare a method like the above, returning NULL is not an option since the method doesn't return a pointer but rather a class.
  So what do I return to indicate that no person is found ?</p>