I'm building a simple student database with pointers and basically a queue. I'm having trouble putting it together as I'd like to keep track of their name and ID..Here's my code thus far..
Code:
class studentList{
public:
int id;
string name;
studentList *next;
};
int main(){
studentList *temp = NULL;
studentList *front = NULL;
studentList *back = NULL;
int id, option;
string name;
do{
cout<<"1. Add New Student"<<endl;
cout<<"2. Delete First Student"<<endl;
cout<<"3. List All Students"<<endl;
cout<<"4. Exit"<<endl;
cout<<"Option: ";
cin>>option;
if(option == 1){
temp = new studentList;
int _id;
string _name;
cout<<"Please Enter Student's Name"<<endl;;
cin>>temp->name;
cout<<"Please Enter Student's ID"<<endl;;
cin>>temp->id;
}
else if(option == 2 && front != NULL){
temp = front;
front = front->next;
delete temp;
}
else if(option == 3){
temp = front;
while(temp){
cout<<temp->name<<endl;
temp = temp->next;
}
}
else if(option == 4){
cout<<"Thanks For Using This Program!!"<<endl;
}
else{
cout<<"Invalid Option"<<endl;
}
}while(option != 4);
return 0;
}