0
pragma solidity ^0.4.24;

contract Bank {
    uint private value;


    function Bank(uint amount) {
        value = 10;
    }

    function deposit(uint amount) {
        value += amount;
    }


    function balance() constant returns (uint) {
        return value;
    }

}

contract MyFirstContract is Bank {
    string private name;
    uint private age;

    function setName(string newName) {
        name = newName;
    }

    function getName() returns (string) {
        return name;
    }

    function setAge(uint newAge) {
        age = newAge;
    }

    function getAge() returns (uint) {
        return age;
    }
}

closed as unclear what you're asking by shane, Achala Dissanayake, Richard Horrocks, eth Sep 16 '18 at 13:54

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

Your child contract does not have a constructor which would call the Bank's constructor. As the Bank contract has a constructor (with parameters), you have to call it in child contracts.

So adding something like this at the beginning of your child contract will make it deploy:

constructor() Bank(1) {

}

Of course you should decide on the exact logic, but hopefully you get the point.

P.S. Is is strongly encouraged to use the keyword constructor for a constructor. The way you are defining your constructor will not be allowed anymore in Solidity version 0.5.

0

You can clean up a lot of warnings by adding public to each function.

In Bank your constructor accepts a uint argument:

function Bank(uint amount)

Since MyFirstContract is Bank you need to define how this value will passed in. For example, add a constructor:

constructor() Bank(0) {}

If you want, you can pass the argument in and pass it through to Bank.

constructor(uint arg1) Bank(arg1) {}

Have a look over here for a more detailed explanation of what's going on here. Inherited Constructors

Hope it helps.

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