I need to split my smart contract because of the size limit, so I created Inheritance. Never did it before. But I got into trouble, I tried to go back to basics and try this code :
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract parent {
uint256 internal id = 9;
function setValue(uint256 _value) public{
id = _value;
}
function getValue1() public view returns (uint256) {
return id;
}
}
contract child is parent {
function getValue2() public view returns (uint256) {
return id;
}
}
Deployed the above contracts on Remix and my question is:
Why when I set Value on parent contract, it can't be read from child contract.
Why Parent and Child have their respective values with the same function?
Need explanation from expert.