Created
January 23, 2023 02:07
-
-
Save nextdev1111/fd27bf8ece853ee77ddef5b4ffc3c564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.4.22 <=0.8.17; | |
// inheritance | |
contract A{ | |
uint x; | |
function setX(uint newX) public virtual { | |
x = newX; | |
} | |
function getX() public virtual view returns(uint){ | |
return 1; | |
} | |
} | |
contract B{ | |
uint y; | |
function setY(uint newY) public{ | |
y = newY; | |
} | |
function getX() public virtual view returns(uint){ | |
return 2; | |
} | |
} | |
contract Child is A,B{ | |
function getX() public override(A,B) view returns(uint){ | |
return super.getX(); // returning 1 instead of 2 | |
} | |
function setX(uint newX) public override{ | |
super.setX(newX); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment