Skip to content

Instantly share code, notes, and snippets.

@ngmachado
Created July 9, 2019 13:07
Show Gist options
  • Save ngmachado/1884b97875654d3aab240c5d1ec9cae9 to your computer and use it in GitHub Desktop.
Save ngmachado/1884b97875654d3aab240c5d1ec9cae9 to your computer and use it in GitHub Desktop.
Override Method
pragma solidity ^0.5.0;
contract ObjectOriented {
event Debug(string msg);
constructor() public {
}
// Base method with two parameters
function A(address _addr, uint256 _value) public returns(uint256) {
assert(_addr == _addr);
emit Debug("Complete Params Methods Call");
return _value;
}
// Sugar method that doesnt require address parameter
function A(uint256 _value) public returns(uint256) {
emit Debug("Encapsulated Method call");
return A(address(this), _value);
}
}
contract Client is ObjectOriented {
function A(uint256 _value) public returns(uint256) {
return super.A(_value);
}
function A(address _addr, uint256 _value) public returns(uint256) {
return super.A(_addr, _value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment