Thermal Ice
Thermal Ice

Reputation: 13

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.

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

Upvotes: 0

Views: 156

Answers (1)

user3074620
user3074620

Reputation: 3977

pragma solidity >=0.4.16 <0.9.0; is your problem.

The keywords virtual and override were added in 0.6.0.

Try

pragma solidity >=0.6.12 <0.9.0;

Upvotes: 1

Related Questions