- child class can use properties of parent class
- e,g
// Parent class
// Vehicle.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract Vehicle {
string public brand;
constructor(string memory _brand){
brand = _brand;
}
function description() public pure virtual returns (string memory){
return "This is a vehical";
}
}
// Child class
// Car.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
import "./Vehical.sol";
contract Car is Vehical{
uint public numberOfDoor;
constructor(string memory _brand, uint _numberOfDoor) Vehical(_brand){
numberOfDoor = _numberOfDoor;
}
function description() public pure override returns (string memory){
return "This is a car";
}
}