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;
}

 

转载于:https://www.cnblogs.com/eilinge/p/10074210.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值