基于以太坊的智能合约开发教程Solidity 结构体
pragma solidity ^0.4.0;
contract structTest{
// 结构体的定义
struct Student{
uint grade;
string name;
bool sex;
uint student_number;
}
struct Student_Two{
uint grade;
string name;
bool sex;
uint student_number;
Student_Two [] stu;
mapping(uint => string) maps;
// 结构体当中不能嵌套结构体本身,但是可以包含动态数组以及mapping映射
}
uint [] memory num = new uint[](7);
num[0] =10;
function init()public pure returns(uint,string){
Student memory s = Student({grade:100,name:"zhangsan",sex:true,student_number:20211010});
return (s.grade,s.name);
}
function init1()public pure returns(uint,string){
Student memory s = Student(100,"zhangsan",true,20211010);
return (s.grade,s.name);
}
}