Solidity Struct Example: Book Information
pragma solidity >=0.7.0 <0.9.0;
contract StructDemo { struct Book { string Name; string publisher; uint price; uint pagecount; }
Book b = Book('aaa', 'bbb', 12, 13);
function getName() public view returns (string memory) {
    return b.Name;
}
function getPublisher() public view returns (string memory) {
    return b.publisher;
}
function getPrice() public view returns (uint) {
    return b.price;
}
function getPageCount() public view returns (uint) {
    return b.pagecount;
}
}
原文地址: https://www.cveoy.top/t/topic/pdpb 著作权归作者所有。请勿转载和采集!