zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    wenbao与筛法素数及判断模板
    wenbao与dfs奇偶剪枝
    wenbao与搜索
    wenbao与反素数
    wenbao与三分
    wenbao与极角排序
    wenbao与差分约束
    wenbao与勒让德定理
    Zotero 导出参考文献列表
    为人性僻耽佳句(三)
  • 原文地址:https://www.cnblogs.com/eilinge/p/10074210.html
Copyright © 2011-2022 走看看