简体   繁体   English

SOLIDITY:[函数覆盖]:-> ParserError:预期为“{”但得到保留关键字“覆盖”

[英]SOLIDITY : [Function Overridding] : -> ParserError: Expected '{' but got reserved keyword 'override'

I am beginner learning solidity....I m trying function overridding but I am unable to do it and I don't know why it shows error.我是初学者学习solidity....我正在尝试功能覆盖,但我无法做到,我不知道为什么它会显示错误。

SPDX-License-Identifier: MIT

pragma solidity >=0.4.16 <0.9.0;

contract parent{

    string public str = "Black";
    function check() public view returns(string memory){
        return str;
    }
}

contract child is parent {
    string public st = "Box";
    function check() public view override returns(string memory){  // why this error?...plz help ;-;
        return string(abi.encodePacked(str,st));
    }
}

pragma solidity >=0.4.16 <0.9.0; is your problem.是你的问题。

The keywords virtual and override were added in 0.6.0.在 0.6.0 中添加了关键字virtualoverride

Try尝试

pragma solidity >=0.6.12 <0.9.0;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Solidity 中的 ParserError,预期的标识符但得到保留关键字“不可变” - ParserError in solidity, Expected identifier but got reserved keyword 'immutable' ParserError:应为“;” 但得到了保留关键字“in” - ParserError: Expected ';' but got reserved keyword 'in' 坚固性:ParserError:预期';' 但得到'(' - solidity: ParserError: Expected ';' but got '(' Solidity ParserError:预期的';' 但得到了“是” - Solidity ParserError: Expected ';' but got 'is' Solidity ParserError:预期的标识符,但得到了 '(' constructor() public { ^ - Solidity ParserError: Expected identifier but got '(' constuctor() public { ^ Solidity 错误:: ParserError: Expected '(' but got 'public' - Solidity Error :: ParserError: Expected '(' but got 'public' "Solidity 错误 :: ParserError: Expected &#39;,&#39; but got &#39;Number&#39;" - Solidity Error :: ParserError: Expected ',' but got 'Number' 无法解决 Solidity 错误 - ParserError: Expected &#39;;&#39; 但得到了“数字”-&gt; first.sol:2:17: | 2 | Pragma 坚固性 0.8.7; | ^^^ - Unable to solve solidity error- ParserError: Expected ';' but got 'Number' --> first.sol:2:17: | 2 | Pragma solidity 0.8.7; | ^^^ 解析器错误:应为“;” 但得到了标识符 - ParserError: Expected ';' but got identifier ParserError:应为“;” 但得到了“事件”——solidity 0.8 address payable(msg.sender) - ParserError: Expected ';' but got 'event' -- solidity 0.8 address payable(msg.sender)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM