Solidity官方文档中的“委托投票”案例remix上运行报错。

问题遇到的现象和发生背景


根据Solidity官方文档学习材料,我按照示范,模仿着编写。但在“为 proposalNames 中的每个提案,创建一个新的(投票)表决”这个位置上出现了报错。

问题相关代码

constructor(bytes32[] proposalNames)  public{
        chairperson = msg.sender;
        voters[chairperson].weight = 1;
        //对于提供的每个提案名称,
        //创建一个新的 Proposal 对象并把它添加到数组的末尾。
        for (uint i = 0; i < proposalNames.length; i++) {
            // `Proposal({...})` 创建一个临时 Proposal 对象,
            // `proposals.push(...)` 将其添加到 `proposals` 的末尾
            proposals.push(Proposal({
                name: proposalNames[i],
                voteCount: 0
            }));
        }
    }

运行结果及报错内容

from solidity:
TypeError: Data location must be "storage" or "memory" for constructor parameter, but none was given.
--> 委托投票案例.sol:31:19:
|
31 | constructor (bytes32[] proposalNames) public {
| ^

我想要达到的结果

如何解决这个这个报错,以及constructor需要是用什么样的定义类型?


 
constructor(bytes32[] memory proposalNames)  public{
        chairperson = msg.sender;
        voters[chairperson].weight = 1;
        //对于提供的每个提案名称,
        //创建一个新的 Proposal 对象并把它添加到数组的末尾。
        for (uint i = 0; i < proposalNames.length; i++) {
            // `Proposal({...})` 创建一个临时 Proposal 对象,
            // `proposals.push(...)` 将其添加到 `proposals` 的末尾
            proposals.push(Proposal({
                name: proposalNames[i],
                voteCount: 0
            }));
        }
    }