[Ethereum] TypeError: Type contract InsuranceClaim is not implicitly convertible to expected type address

blockchainsolidity

I am confused why the following code is not working. Any help would be greatly appreciated.

pragma solidity >=0.4.22 <0.6.0

contract InsuranceClaimFactory{
    address public claimer;
    address[] public deployedInsuranceClaim;
    function createInsuranceClaim () public {
        address newInsuranceClaim = new InsuranceClaim(msg.sender);
        deployedInsuranceClaim.push(newInsuranceClaim);
    }

    function getDeployedInsuranceClaims () public view returns (address[] memory){
        return deployedInsuranceClaim;
    }
}

The constructor for InsuranceClaim is

constructor (address creator) public {
claimer=creator;
}

The error is

TypeError: Type contract InsuranceClaim is not implicitly convertible
to expected type address

Best Answer

ERROR: Type contract InsuranceClaim is not implicitly convertible to expected type address means you can not store InsuranceClaim type of object in address variable. AS per solidity version 0.5.0 Documentation you can define and use InsuranceClaim like this:

pragma solidity>0.4.99<0.6.0;

contract InsuranceClaimFactory{
    address public claimer;
   
    InsuranceClaim[] public deployedInsuranceClaim;
    function createInsuranceClaim () public {
        InsuranceClaim newInsuranceClaim = new InsuranceClaim(msg.sender);
        deployedInsuranceClaim.push(address(newInsuranceClaim));
    }

    function getDeployedInsuranceClaims () public view returns (InsuranceClaim[] memory){
        return deployedInsuranceClaim;
    }
}