solidity 将数据位置从内存更改为存储

编程入门 行业动态 更新时间:2024-10-04 17:17:32

solidity 将数据位置从<a href=https://www.elefans.com/category/jswz/34/1771154.html style=内存更改为存储"/>

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 将数据位置从内存更改为存储

本文发布于:2024-05-30 19:43:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1770851.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内存   位置   数据   solidity

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!