[Ethereum] storage and memory error

remixsolidity

I am trying to execute the following example listed in the documentation using solidity 0.4

pragma solidity ^0.4.0;
contract C {
    uint[] data1;
    uint[] data2;

    function appendOne() {
        append(data1);
    }

    function appendTwo() {
        append(data2);
    }

    function append(uint[] storage d) {
        d.push(1);
    }
}

But I get the error:

Error: Location has to be memory for publicly visible functions (remove the "storage" keyword).

When I remove the storage keyword I get another error:

Error: Member "push" is not available in uint256[] memory outside of storage.
d.push(1);

Any solution?

Best Answer

try to use internal or private modifier :

pragma solidity ^0.4.0;
contract C {
    uint[] data1;
    uint[] data2;

    function appendOne() {
        append(data1);
    }

    function appendTwo() {
        append(data2);
    }

    function append(uint[] storage d) internal{
        d.push(1);
    }
}