码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-12-06 01:32:56      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:set   pen   mem   类型   contract   ase   忽略   不同   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;
}

 

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

标签:set   pen   mem   类型   contract   ase   忽略   不同   ethereum   

原文地址:https://www.cnblogs.com/eilinge/p/10074210.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!