Inheritance
Example
contract Animal {
string public species;
constructor(string memory _species) {
species = _species;
}
function speak() public view returns (string memory) {
return "Animal speaks";
}
}
contract Dog is Animal {
constructor() Animal("Dog") {}
function speak() public view returns (string memory) {
return "Bark";
}
}
Last updated