I had passed the value(key value pair) to a mapping in parent contract from child contract for updating and the program executes without any error. But when I enter key in the mapping from parent contract it shows like nothing stored in the mapping. Can someone give me any solution?

pragma solidity >0.4.0;
contract admin{
struct patient{
string name;
uint age;

mapping(uint=>patient) public pdb;

function reg(uint id,string memory pname, uint p_age) public {


contract user is admin{
function vacc_reg(uint id,string memory name, uint a) public{
  • Hey RSK, welcome to StackExchange. For us to be able to help you out, you may need to share a code snippet that reproduces the error. Commented Jun 22, 2021 at 10:16
  • attached the code :)
    – rsk
    Commented Jun 22, 2021 at 10:27

1 Answer 1


I think you're confusing being a "parent contract" with the idea of inheritance. This answer does a really good job of differentiating between the two with code samples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.