Openzeppelin
擴展合約時如何呼叫外部建構子並傳遞參數?
我有以下契約
import "zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol"; contract Contract is ERC721Token { function Contract(string _name, string _symbol) public { name_ = _name; // This does not work because name_ is internal symbol_ = _symbol; // This does not work because symbol_ is internal } }
ERC721Token 合約在**建構子中設置了一個****name_**變數,如何呼叫這個建構子或從這個合約設置 var?
您可以呼叫超級建構子作為聲明的一部分:
constructor(string _name, string _symbol) ERC721Token(_name, _symbol) public { // Any additional constructor code you need }