这是我最后的请求帮助 . 我的代码一直在停止,我不知道为什么?

vector<Student>students;
Student *s[20];
int i = 0;
char answer, answer2;
cout << "Add new student? [y/n] ";
cin >> answer;
while (answer == 'Y' || answer == 'y'){
    cout << "Are they a student worker? [y/n] ";
    cin >> answer2;
    if (answer2 == 'Y' || answer2 == 'y'){
        StuWorker *sw = new StuWorker();
        sw->read();
        s[i] = sw;
        i++;
        students.push_back(*sw);
    }
    else{
        Student *sdt = new Student();
        sdt->read();
        s[i] = sdt;
        i++;
        students.push_back(*sdt);
    }
    cout << "\nAdd new student? [y/n]";
    cin >> answer;
}

请帮助我理解为什么我的代码不起作用 . 我被教导要取消引用指针是这样做的 .

我老实说只是输入其他东西,因为堆栈溢出拒绝让我发布这个,除非我输入其他东西 .

UPDATE: StuWorker是一个派生自Student类的类
此外,在第二次迭代后,我的代码停止
还有,当我向我的教授请求关于push_back的帮助时,他发送的所有内容都是:

Vector<Student> v; //just an example   
Student *pointer_to_student = new Student;   
V.push *pointer_to_student;

这是他的指示的第一部分,一个字一个字 . 如果我不理解这些说明,请告诉我:
在main()中,创建一个Student对象的向量,并不断询问用户是否要添加学生 . 如果答案是'y'或'Y',请询问被添加的学生是否是学生工作者 . 如果是,则为StuWorker分配内存,如果没有,为Student分配内存,并在每种情况下,将其添加到最大大小为20的Student指针数组(不直接放入向量中) . 对于动态创建的每个Student或StuWorker,调用已创建的对象's read() function to read data from the user. This should be okay since a student worker is a Student, too and depending on the type of object that',正确的类's read() is called (this is the polymorphism part). As each object is created and data read into it, push it into the vector declared earlier. Continue as long as the user answers with ' y ' or ' Y'到"Add student?"问题 .

这是学生的read():

void Student::read(){
cout << "\nEnter Student's name: ";
cin.ignore();
getline(cin, name);
cout << "Enter Student's ID: ";
getline(cin, idN);
cout << "Enter units completed by Student: ";
cin >> units;
cout << "Enter student's GPA: ";
cin >> gpa;

}

这是StuWorker的read():

void StuWorker::read(){
    Student::read();
    cout << "Enter hours assigned per week: ";
    cin >> hours;
    cout << "Enter hourly rate: ";
    cin >> hourlyRate;
}