title: how can i make this function return null?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2639255/c-return-a-null-object-if-search-result-not-found">C++ return a “NULL” object if search result not found</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to return NULL on a certain condition but it won't let me, why not and how can i make it return a null value or 0?</p>
  
  <pre><code>struct Entity
  {
      USHORT X;
      USHORT Y;
      UINT Serial;
      USHORT SpriteID;
      EntityType Type;
      Direction FacingDirection;
  };
  </code></pre>
  
  <p>the function is:</p>
  
  <pre><code>Entity&amp; GetEntityAt(int index)
                  {
                      if (!GameObjects.empty())
                      {
                          lock_guard&lt;mutex&gt; lock(PadLock);
                          Entity&amp; result = GameObjects[index];
                          return result;
                      }
                      return NULL; // &lt;- this won't compile
                  }
  </code></pre>