title: how can I check if an object exists in C++
body: <p>I am trying to write a function that will check if an object exists:</p>
  
  <pre><code>bool UnloadingBay::isEmpty() {
      bool isEmpty = true;
      if(this-&gt;unloadingShip != NULL) {
          isEmpty = false;
      }
      return isEmpty;
  }
  </code></pre>
  
  <p>I am pretty new to C++ and not sure if my Java background is confusing something, but the compiler gives an error:</p>
  
  <pre><code>UnloadingBay.cpp:36: error: no match for ‘operator!=’ in ‘((UnloadingBay*)this)-&gt;UnloadingBay::unloadingShip != 0’
  </code></pre>
  
  <p>I can't seem to figure out why it doesn't work.</p>
  
  <p>Here is the declaration for class UnloadingBay:</p>
  
  <pre><code>class UnloadingBay {
  
      private:
          Ship unloadingShip;
  
      public:
          UnloadingBay();
          ~UnloadingBay();
  
          void unloadContainer(Container container);
          void loadContainer(Container container);
          void dockShip(Ship ship);
          void undockShip(Ship ship);
          bool isEmpty();
  
  };
  </code></pre>