pragma solidity ^0.4.18; // Defining contract contract Parent { // Declaring internal // state variable uint internal sum; // Defining external function // to set value of internal // state variable sum function setValue() external { uint a = 10; uint b = 20; sum = a + b; } // Adding a getter function for 'sum' function getValue() external view returns (uint) { return sum; } } // Inheriting from Parent contract contract Child is Parent {} // Defining calling contract contract Caller { // Creating child contract object Child cc = new Child(); // Defining function to call // setValue and getValue functions function testInheritance() public returns (uint) { cc.setValue(); return cc.getValue(); } }
0.4.18