Skip to content

Instantly share code, notes, and snippets.

@nextdev1111
Created January 23, 2023 02:07
Show Gist options
  • Save nextdev1111/fd27bf8ece853ee77ddef5b4ffc3c564 to your computer and use it in GitHub Desktop.
Save nextdev1111/fd27bf8ece853ee77ddef5b4ffc3c564 to your computer and use it in GitHub Desktop.
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