TypeError:函数中的参数的数据位置必须是"memory",但没有给出

joh*_*mbi 4 solidity

pragma solidity ^ 0.5.0;

contract memeRegistry {

pragma solidity ^0.5.0;

contract memeRegistry {
    string url;
    string name;
    uint timestamp;

    function setmeme(string _url,string _name, uint _timestamp) public{
        url = _url;
        name = _name;
        timestamp = _timestamp;   
    }
}
Run Code Online (Sandbox Code Playgroud)

}

Yeg*_*mba 8

现在必须显示struct,array或mapping类型的所有变量的显式数据位置.这也适用于函数参数和返回变量.

memory之后添加string

function setmeme(string memory _url, string memory _name, uint _timestamp) public{
Run Code Online (Sandbox Code Playgroud)

点击此处查看Solidity 0.5.0.更改https://solidity.readthedocs.io/en/v0.5.0/050-breaking-changes.html


Kar*_*iga 5

//The version I have used is 0.5.2

pragma solidity ^0.5.2;

contract Inbox{


string public message;

//**Constructor** must be defined using “constructor” keyword

//**In version 0.5.0 or above** it is **mandatory to use “memory” keyword** so as to 
//**explicitly mention the data location**

//you are free to remove the keyword and try for yourself

 constructor (string memory initialMessage) public{
 message=initialMessage;
 }

 function setMessage(string memory newMessage)public{
 message=newMessage;

 }

 function getMessage()public view returns(string memory){
 return message;
 }
}
Run Code Online (Sandbox Code Playgroud)


nik*_*dis 1

选择不同版本的 Solidity 编译器。^0.4.25对我有用。

必须在文件和 remix 的编译选项卡中设置 Solidity 编译器的版本(它是一个下拉菜单)。