Created
January 29, 2023 17:09
-
-
Save ArslanKathia/12c036d21a49f5b97db2ce617734f3bb 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{ | |
uint public a; | |
constructor(){ | |
a = 100; | |
} | |
function funA() public{ | |
a = 10; | |
} | |
//to this function override in derived class use virtual keyword in it | |
function func() public pure virtual returns(string memory){ | |
return "this is func A"; | |
} | |
} | |
contract B is A{ | |
uint public b; | |
constructor(){ | |
b =200; | |
a = 777; | |
} | |
function funB() public{ | |
b =20; | |
} | |
function func() public pure virtual override returns(string memory){ | |
return "this is func B"; | |
} | |
} | |
contract C is A,B{ | |
function func() public pure override(A,B) returns(string memory){ | |
return "this is function in contract c"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment