Dynamically allocate memory for struct

前端 未结 8 649
自闭症患者
自闭症患者 2020-12-31 12:21

I am taking a C++ class and have a assignment which requires me to dynamically allocate memory for a struct. I don\'t recall ever going over this in class and we only brief

8条回答
  •  春和景丽
    2020-12-31 12:42

    The new statement returns a pointer to the newed instance. So you need to defined the student1 as a pointer.

    struct Student * student1 = new Student;
    

提交回复
热议问题