title: C++ Detecting an implicit cast of 0 to a class
body: <p>I am calling a function in a API that returns a <code>Answer</code> object. Under some conditions, the API will return <code>EMPTY_answer</code>, which is defined as such:</p>
  <pre><code> #define EMPTY_answer ((Answer)0)
  </code></pre>
  <p>of course, attempting to access a <code>Answer</code> variable or function from an <code>EMPTY_answer</code> object crashes the application.</p>
  <p>Trying to test for it using <code>if(lAnswer == EMPTY_answer)</code> also crashes the application. Is there any way to detect if the API is returning <code>EMPTY_answer</code>?</p>
  <h3>Edit:</h3>
  <p>I didn't code the api and I can't modify it in any way, I'm just digging through .h files trying to figure this out. And yes, I am aware that casting 0 to a class is a bit <em>too</em> creative to put it mildly. I just noticed that the <code>==</code> operator is overridden</p>
  <pre><code>(...)
  class ExportedByJS0CORBA Answer
  {
     (...)
     int __stdcall operator==(Answer *ipt) const;
  }
  </code></pre>
  <p>the function being called is</p>
  <pre><code>static SubClassOfAction Query();
  </code></pre>
  <p>I'm simplifying names and quite a few layers of inheritance
  To be more precise, it crashes with a Segmentation Fault.</p>