hi, i am trying to check whether the ship object is null, but i got an error message
Crane.cpp:18: error: could not convert ‘((Crane*)this)->Crane::ship.Ship::operator=(((const Ship&)(& Ship(0, std::basic_string, std::allocator >(((const char*)"arrive"), ((const std::allocator&)((const std::allocator*)(& std::allocator())))), std::basic_string, std::allocator >(((const char*)"Ship"), ((const 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) //this is the problem
{
cout << " " << endl;
}
else
{
ship.print();//i have another print method in the Ship class
}
}
i have 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 this right?
thank you