Last active
January 1, 2020 22:22
-
-
Save rezarahimian/26307ae912605d2670ca42470124c794 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.5.0; | |
contract Mul | |
{ | |
function Mul_v1(uint[50] calldata array, uint i, uint j) external pure returns(uint c) { return array[i] * array[j]; } | |
function Mul_v2(uint[50] memory array, uint i, uint j) public pure returns(uint c) { return array[i] * array[j]; } | |
function Mul_v3(uint[50] memory array, uint i, uint j) internal pure returns(uint c) { return array[i] * array[j]; } | |
} | |
//Deriving from Mul contract | |
contract Cof is Mul | |
{ | |
uint[50] private data; | |
constructor() public | |
{ | |
data[0] = 5; | |
data[49] = 2; | |
} | |
function Cof_v1() public view returns(uint r) { return this.Mul_v1(data, 0, 49); } | |
function Cof_v2() public view returns(uint r) { return Mul_v2(data, 0, 49); } | |
function Cof_v3() public view returns(uint r) { return Mul_v3(data, 0, 49); } | |
} | |
//Referencing to Mul contract | |
contract Pow | |
{ | |
uint[50] private data; | |
Mul private m; | |
constructor() public | |
{ | |
m = new Mul(); | |
data[0] = 5; | |
} | |
function Pow_v1() public view returns(uint r) { return m.Mul_v1(data, 0, 0); } | |
function Pow_v2() public view returns(uint r) { return m.Mul_v2(data, 0, 0); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment