I am trying to check if the ship object is null, but I got an error
Crane.cpp: 18: error: cannot convert '((Crane *) this) → Crane :: ship.Ship :: operator = (((const Ship &) (& Ship (0, std :: basic_string, std :: allocator> (((const char *) "come"), ((const std :: allocator &) ((const std :: allocator) (& std :: allocator ()))) (std :: allocator &) ( (const std :: allocator *) (& std: :) allocator ())))))))) to 'bool
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 << "Crane Id: " << craneId << endl;
cout << "Crane Status: " << craneStatus << endl;
cout << "Crane is free: " << free << endl;
if (ship = NULL)
{
cout << " " << endl;
}
else
{
ship.print();
}
}
I tried
if (ship == NULL)
but i get this error message
Crane.cpp: 18: error: no match for 'operator == in' ((Crane *) this) -> Crane :: ship == 0
how to do it right?
source
share