Witam
Może mi ktoś powiedzieć co tu zrobiłem źle że program się kompiluje ale po wprowadzeniu danych, gdy ma już dodać element do listy się zawiesza ?
[code]#include <string>
#include <iostream>
using namespace std;
class student {
public:
string imie;
string nazwisko;
};
typedef struct list{
struct list *next,*prev;
student key;
}lista;
void push(lista *&head,student x){
lista *nowy= new lista;
lista *tmp= new lista;
nowy->key = x;
nowy->next = NULL;
if(head) {
tmp=head;
while(tmp->next) tmp=tmp->next;
tmp->next=nowy;
nowy->prev = head;
}
else {
head=nowy;
tmp->prev=NULL;
}
}
class dziekanat{
public:
lista *head;
void DodajStudenta();
};
void dziekanat::DodajStudenta(){
student *x = new student;
cout<<"podaj imie"<<endl;
cin>>x->imie;
cout<<"nazwisko"<<endl;
cin>>x->nazwisko;
push(head,*x);
}
void show(lista *head){
while(head) {
cout<<head->key.imie<<endl;
head=head->next;
}
}
int main(){
dziekanat lol;
lol.DodajStudenta();
getchar();
getchar();
return 0;
}[/code]