hi everyone..im trying to create a student list program using linked list that will display all my info of students..but it seems theres a little prob. after i enter my first student the program will exit.. can somebody help me please. thank you
#include <stdlib.h>
#include <iostream.h>
#include <string.h>
#include <conio.h>
class student {
char name[30];
char gender[6];
int age;
student *next;
friend stud_list;
public:
student() {
cout << "Name: "; cin >> name; cout << endl;
cout << "Gender: "; cin >> gender; cout << endl;
cout << "Age: "; cin >> age; cout << endl;
next=NULL;
};
~student() {
cout << "Deleted!" << endl;
};
void display();
};
class stud_list {
int count;
student *first, *last;
public:
stud_list() {
count=0;
first=NULL; last=NULL;
};
~stud_list() {
cout << "List Deleted\n";
};
public:
void insert_at_end(student *a);
void insert_as_first(student *a);
};
void stud_list::insert_as_first(student *a) {
first=a;
last=first;
};
void student::display() {
cout << "Name: " << name << endl;
cout << "Gender: " << gender << endl;
cout << "Age: " << age << endl;
}
int main()
{
kdf
student a;
a.display();
getche();
return 0;
}