内存更改为存储"/>
solidity 将数据位置从内存更改为存储
嗨我有这个代码,错误是:
UnimplementedFeatureError:尚不支持将类型 struct spu_university.all_courses 内存 [] 内存复制到存储。
我怎么解决这个问题??
// SPDX-许可证标识符:麻省理工学院 pragma solidity >=0.4.22 <0.9.0;
合同spu_university {
address is_admin;
constructor(){
is_admin = msg.sender;
}
modifier onlyAdmin(address x) {
require(x== is_admin, "Permission Denied. You do not have admin access.");
_; }
uint s_counter=0;
struct students_marks{
uint id;
uint mark;
}
struct all_courses{
string course_name ;
uint mark ;
}
struct warning {
string date ;
string description;
}
struct course {
string name ;
uint id;
uint weekly_hours;
uint level ;
students_marks[] marks;
}
struct prof {
uint id ;
string firstName;
string lastName;
string fatherName;
string motherName;
string gender;
string email;
string collegeName;
string dateOfBirth;
string mobileNumber;
string specialization ;
}
struct student {
uint id ;
string firstName;
string lastName;
string fatherName;
string motherName;
string gender;
string email;
string collegeName;
string dateOfBirth;
string mobileNumber;
all_courses[] course;
warning[] s_warnings;
}
student[] studentList ;
prof[] profList;
course[] courselist;
mapping(uint => student) public getstudent;
mapping(uint => prof) public getprof;
mapping(uint => course) public getcours;
//--------------------------------注册函数------------ ------------------------------------------
function registerStudent(
uint _id,
string memory _firstName,
string memory _lastName,
string memory _fatherName,
string memory _motherName,
string memory _gender,
string memory _email,
string memory _collegeName,
string memory _dateOfBirth,
string memory _mobileNumber
) onlyAdmin(msg.sender) public {
student memory x= student(_id,_firstName,
_lastName,_fatherName,_motherName,_gender,
_email,_collegeName,_dateOfBirth,
_mobileNumber,
new all_courses[] (0),
new warning[] (0) );
studentList.push(x);
getstudent[_id]=studentList[s_counter];
s_counter ++;
}
}
我试了很多东西都不管用
回答如下:更多推荐
solidity 将数据位置从内存更改为存储
发布评论