26/05/09 18:06
frankus89
questo il codice che implementa una coda dinamica:
gli errori in fase di compilazione che non riesco a spiegarmi sono:
lista in c++.cpp:19: error: new types may not be defined in a return type
lista in c++.cpp:19: note: (perhaps a semicolon is missing after the definition of ‘LISTA’)
lista in c++.cpp:19: error: two or more data types in declaration of ‘main’
lista in c++.cpp:48: error: no ‘void LISTA::inserisci(LISTA*, int)’ member function declared in class ‘LISTA’
lista in c++.cpp:64: error: no ‘int LISTA::estrai(LISTA*)’ member function declared in class ‘LISTA’
spero possiate aiutarmi..saluti!
#include <iostream> using namespace std; class LISTA{ int n; LISTA *prox; public: LISTA* inizializza(); friend void inserisci(LISTA*,int); friend int estrai(LISTA*); } int main() { LISTA * boss; int numero,scelta,est; boss=inizializza(); for (;;) { cout<<"opzione: \n"; cout<<"1) inserisci in coda \n"; cout<<"2)estrai \n"; cout<<"scelta: "; if (scelta == 1) { cout<<"numero: "; cin>>numero; inserisci(boss,numero); } if (scelta == 2) { est=estrai(boss); return 0; } } } LISTA* LISTA::inizializza() { LISTA *aus; aus = NULL; return aus; } void LISTA::inserisci(LISTA* p,int k){ LISTA *aus,*x; if (p==NULL) { x = new LISTA; x->n=k; x->prox=NULL; x=p; } while (aus->prox!=NULL) aus=aus->prox; x=new LISTA; x->n=k; x->prox=NULL; aus=x; } int LISTA::estrai(LISTA* p){ LISTA *aus,*x; if (p==NULL) cout<<"impossibile estrarre"; while(aus->prox!=NULL) aus=aus->prox; return aus->n; }
gli errori in fase di compilazione che non riesco a spiegarmi sono:
lista in c++.cpp:19: error: new types may not be defined in a return type
lista in c++.cpp:19: note: (perhaps a semicolon is missing after the definition of ‘LISTA’)
lista in c++.cpp:19: error: two or more data types in declaration of ‘main’
lista in c++.cpp:48: error: no ‘void LISTA::inserisci(LISTA*, int)’ member function declared in class ‘LISTA’
lista in c++.cpp:64: error: no ‘int LISTA::estrai(LISTA*)’ member function declared in class ‘LISTA’
spero possiate aiutarmi..saluti!
aaa