1. 程式人生 > >ethereum(以太坊)(基礎)--容易忽略的坑(一)

ethereum(以太坊)(基礎)--容易忽略的坑(一)

pragma solidity ^0.4.0;

contract base{
    address public _owner=msg.sender;
    uint _a;
    string internal _b ;
    uint private _c;
    //uint external _d;ParserError: Expected identifier but got 'external'
    
    function base() {
        _a =10;
        //uint  _d public;Expected ';' but got 'public'
string _f; } function getA() public view returns (uint){ return _a; } function setA(uint c) internal{ _a=c; } //modifier OnlyAdmin() private{Expected '{' but got 'private' modifier OnlyAdmin(){ require(_owner == msg.sender); _; }
function kill() OnlyAdmin() external{ setA(6); this.getA(); selfdestruct(msg.sender); } } contract base1 is base{ function getA() public view returns(uint){ //return _c;DeclarationError: Undeclared identifier. Did you mean "_a" or "_b"? //return _b;Overriding function return types differ:覆蓋函式返回型別不同
return _a; } function getE(){ this.kill(); this.getA(); //this.setA(20);Member "setA" not found or not visible after argument-dependent lookup in contract base1 } } contract base2{ uint public _e; function getE(){ //this.getA();Member "getA" not found or not visible after argument-dependent lookup in contract base2 } } //contract base2 is base1,base{ Linearization of inheritance graph impossible:繼承圖的線性化是不可能的 contract base3 is base,base1{ uint public _e; }