Prova così :
codice:#include <iostream.h> typedef struct servizio { int numero; int stato; //0 libero, 1 occupato union { int richiesta; int posizione; int tempo; servizio *succ; } coda; servizio *next; } posta; posta *inizializza( int postaNum) { posta *first = new posta, *tmp = first; for( int i=0; i<postaNum; i++) { tmp->numero = i+1; tmp->stato = 0; tmp->next = new posta; tmp = tmp->next; } tmp->next=NULL; return first; } int main() { posta *sportello = inizializza( 5 ); while(sportello->next!=NULL) { cout<<"Sportello "<<sportello->numero<<endl; sportello=sportello->next; } return 0; }

Rispondi quotando