區塊鏈學堂(24) Struct型別

2021-08-14 08:38:15 字數 1142 閱讀 6971

例如定義乙個struct型別的person

struct person
pragma solidity 0.4.10;

contract demotypes9

person public personlist;

}

最初的合約只定義了struct person型別,以及乙個陣列person personlist

step 1-2後,完整**如下:

pragma solidity 0.4.10;

/*演示一下結構,如何和陣列型別結合,一起使用;*/

contract demotypes9

person public personlist;

function demotypes9()

}

以上**在browser-solidity中的執行結果如下圖所示:

function addperson (string _name, uint _***y, uint _age, string _mobile)
browser-solidity的執**況如下:

function addperson2 (string _name, uint _***y, uint _age, string _mobile) );

}

addperson2() 的方法簡潔了很多

browser-solidity的執**況如下

pragma solidity 0.4.10;

/*演示一下結構,如何和陣列型別結合,一起使用;*/

contract demotypes9

person public personlist;

function demotypes9()

function addperson (string _name, uint _***y, uint _age, string _mobile)

function addperson2 (string _name, uint _***y, uint _age, string _mobile) );}}

原文:

區塊鏈學堂(20) Int型別

int uint signed and unsigned integers of various sizes.keywords uint8 to uint256 in steps of 8 unsigned of 8 up to 256 bits and int8 to int256.uint an...

區塊鏈學堂(20) Int型別

int uint signed and unsigned integers of various sizes.keywords uint8 to uint256 in steps of 8 unsigned of 8 up to 256 bits and int8 to int256.uint an...

區塊鏈學堂(15) Mist

建立鏈條的geth命令 geth datadir init genesis.json geth datadir nodiscover console 2 geth.log 在命令列模式下,新建賬號,並且啟動挖礦 personal.newaccount 123 0x48ad44beba68a981e1...