pragma solidity 0.4.8;
// These abstract contracts are only provided to make the
// interface known to the compiler. Note the function
// without body. If a contract does not implement all
// functions it can only be used as an interface.
// Let me write an abstract contract with a single function and then extend it
// in the new contract and then override it there.
contract Feline {
// This is how we write the abstract contract
function utterance() returns (bytes32);
}
// inherit the contract in cat and then override the function utterance with some full definition
contract Cat is Feline {
function utterance() returns (bytes32) { return "miaow"; }
}
感谢您对本文的关注,如果您对区块链技术有兴趣,可以加入我们一起探讨, 请扫码关注“可可链”的微信公众号,并留言“加入可可链”。
本文欢迎转载,转载时请注明本文来自 微信公众号“可可链”。