title: Null object in c++
body: <p>i am trying to check whether the ship object is null, but i got an error message</p>
  
  <blockquote>
    <p>Crane.cpp:18: error: could not convert ‘((Crane*)this)->Crane::ship.Ship::operator=(((const Ship&amp;)(&amp; Ship(0, std::basic_string, std::allocator >(((const char*)"arrive"), ((const std::allocator&amp;)((const std::allocator<em>)(&amp; std::allocator())))), std::basic_string, std::allocator >(((const char</em>)"Ship"), ((const std::allocator&amp;)((const std::allocator*)(&amp; std::allocator()))))))))’ to ‘bool’</p>
  </blockquote>
  
  <pre><code>Crane::Crane(int craneId, int craneStatus, bool free, Ship ship)
  {
      setCraneId(craneId);
      setCraneStatus(craneStatus);
      setFree(free);
      setShip(ship);
  }
  Crane::Crane(){}
  Crane::~Crane(){}
  
  void Crane::print()
  {
      cout &lt;&lt; "Crane Id: " &lt;&lt; craneId &lt;&lt; endl;
      cout &lt;&lt; "Crane Status: " &lt;&lt; craneStatus &lt;&lt; endl;
      cout &lt;&lt; "Crane is free: " &lt;&lt; free &lt;&lt; endl;
      if (ship = NULL) //this is the problem
      {
          cout &lt;&lt; " " &lt;&lt; endl;
      }
      else
      {
          ship.print();//i have another print method in the Ship class
      }
  }
  </code></pre>
  
  <p>i have tried </p>
  
  <pre><code>if (ship == NULL) 
  </code></pre>
  
  <p>but i get this error message</p>
  
  <blockquote>
    <p>Crane.cpp:18: error: no match for ‘operator==’ in ‘((Crane*)this)->Crane::ship == 0’</p>
  </blockquote>
  
  <p>how to do this right?</p>