自定义结构体
pragma solidity ^0.4.4;
contract Students {
struct Person {
uint age;
string name;
}
}
Person
就是我们自定义的一个新的结构体类型,结构体里面可以存放任意类型的值。
初始化一个结构体
- 方法一
pragma solidity ^0.4.4;
contract Students {
struct Person {
uint age;
string name;
}
Person _person = Person(18,"wsj");
}
- 方法二
pragma solidity ^0.4.4;
contract Students {
struct Person {
uint age;
string name;
}
Person _person = Person({age:18,name:"wsj"});
}