Created
January 29, 2023 17:40
-
-
Save ArslanKathia/9148bd29e6918b54ecf059c918d64b4b to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
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
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
contract A{ | |
event log(string text,uint age); | |
function fun1() public virtual{ | |
emit log("A.fun1",21); | |
} | |
function fun2() public virtual{ | |
emit log("A.fun2",22); | |
} | |
} | |
contract B is A{ | |
function fun1() public virtual override{ | |
emit log("B.fun1",31); | |
A.fun1(); //direct calling | |
} | |
function fun2() public virtual override{ | |
emit log("B.fun2",32); | |
super.fun2(); //super called function from right most to depth | |
} | |
} | |
contract C is A{ | |
function fun1() public virtual override{ | |
emit log("C.fun1",41); | |
A.fun1(); //direct calling | |
} | |
function fun2() public virtual override{ | |
emit log("C.fun2",42); | |
super.fun2(); //super called function from right most to depth | |
} | |
} | |
contract D is B,C{ | |
function fun1() public override(B,C){ | |
emit log("D.fun1",51); | |
B.fun1(); //direct calling | |
} | |
function fun2() public override(B,C){ | |
emit log("D.fun2",52); | |
super.fun2(); //super called function from right most to depth | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment