0

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 {
pdb[id].name=pname;
pdb[id].age=p_age;
}

}

contract user is admin{
function vacc_reg(uint id,string memory name, uint a) public{
   reg(id,name,a);
}
}
2
  • 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

0

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.