Salve a tutti,
sto cercando di implementare un progetto in C++ sotto windows, mediante l'utilizzo di devc++.
Il progetto è composto di un file header in cui sono dichiarate le classi:
esami.h
Di un sorgente che implementa i metodi, ma non ancora tutti gli ho sviluppaticodice:#ifndef _DB_ESAMI #define _DB_ESAMI #include <iostream> #include <string> using std::string; class esame { public: esame(); esame(string); esame(string,int); string getEsame(); // restituisce il nome dell'esame int getVoto(); // restituisce il voto ottenuto per l'esame se sostenuto void setVoto(int); // imposta il voto ottenuto per l'esame void setEsame(string); // imposta il nome dell'esame void setSostenuto(bool); bool isSostenuto(); // restituisce true se l'esame è stato sostenuto private: string nome_esame; bool sostenuto; int voto; }; /*------------------------------------------------------*/ class studente { public: studente(); //imposta i nomi di default dei 5 esami e i rispettivi flag sostenuto a false studente(string, string, string, string, string); // imposta in nomi dei 5 esami usando i parametri nome1, ... e i rispettivi flag sostenuto a false void setMatricola( string); void setNome(string ); void setEsame(int ,int); // imposta il voto dell'esame i-esimo string getMatricola(); string getNome(); int getNumEsami(); //restituisce 5 (numero massimo di esami da sostenere) int getVotoEsame(int); string getNomeEsame(int); bool getSostenuto(int) ; float getMedia();// restituisce la media degli esami sostenuti void printStudente(string ); //visualizza tutte le informazioni dello studente compresi gli esami sostenuti e i rispettivi voti private: string nome_studente; string matricola; int numero_esami; esame esami[5]; }; /*------------------------------------------------------*/ class studenti { public: studenti(); void print_studenti(); private: studente stud[3]; }; #endif /* _DB_ESAMI */
esami.cpp
Da un main per la prova dei metodi, anchesso non ancora del tutto completatocodice:#include "esami.h" esame::esame() { setVoto(0); setEsame("NULL"); setSostenuto(false); } esame::esame(string nome_esame) { setVoto(0); setEsame(nome_esame); setSostenuto(false); } esame::esame(string nome_esame,int voto_esame) { setVoto(voto_esame); setEsame(nome_esame); setSostenuto(true); } string esame::getEsame() { return esame::nome_esame; } int esame::getVoto() { return esame::voto; } void esame::setVoto(int votazione) { esame::voto=votazione; setSostenuto(true); } void esame::setEsame(string nome_e) { esame::nome_esame=nome_e; } void esame::setSostenuto(bool sost) { esame::sostenuto=sost; } bool esame::isSostenuto() { return esame::sostenuto; } /*---------------------------------------------------------------*/ studente::studente() { setNome(""); setMatricola(""); studente::numero_esami = 5; } studente::studente(string esame1, string esame2, string esame3, string esame4, string esame5) { setNome(""); setMatricola(""); studente::numero_esami = 5; esami[0].setEsame(esame1); esami[1].setEsame(esame2); esami[2].setEsame(esame3); esami[3].setEsame(esame4); esami[4].setEsame(esame5); } void studente::setMatricola(string matr) { studente::matricola=matr; } void studente::setNome(string name) { studente::nome_studente=name; } void studente::setEsame(int num_esame ,int voto) { esami[num_esame].setVoto(voto); } string studente::getMatricola() { return matricola; } string studente::getNome() { return nome_studente; } int studente::getNumEsami() { return numero_esami; } int studente::getVotoEsame(int num_es) { return esami[num_es].getVoto; } string studente::getNomeEsame(int num_es) { return esami[num_es].getEsame; }/* bool getSostenuto(int) { } float studente::getMedia() { } void studente::printStudente(string ) { } /*---------------------------------------------------------------*/ /* studenti::studente() { } void studenti::print_studenti() { } */
main.cpp
Quando provo a compilare riscontro i seguenti errori:,codice:#include "esami.h" using namespace std; int main(int argc, char *argv[]) { esame asd; esame asd2("ASD2"); esame asd3("ASD3",30); cout << "nome esame: " << asd.getEsame() << endl; cout << "voto: " << asd.getVoto() << endl; cout << "sostenuto: " << asd.isSostenuto() <<endl << endl; cout << "nome esame: " << asd2.getEsame() << endl; cout << "voto: " << asd2.getVoto() << endl; cout << "sostenuto: " << asd2.isSostenuto() <<endl << endl; cout << "nome esame: " << asd3.getEsame() << endl; cout << "voto: " << asd3.getVoto() << endl; cout << "sostenuto: " << asd3.isSostenuto() <<endl << endl; system("PAUSE"); }
Si riferiscono entrambi al file sulla dichiarazione dei metodi e la linea 102 riguarda la classe studente::getVotoEsame dove non fa altro che far ritornare "esami[num_es].getVoto;"codice:C:\Users\Neptune\Desktop\Asd\laboratorio\3-11-2010\esami.cpp In member function `int studente::getVotoEsame(int)': 102 C:\Users\Neptune\Desktop\Asd\laboratorio\3-11-2010\esami.cpp argument of type `int (esame::)()' does not match `int' C:\Users\Neptune\Desktop\Asd\laboratorio\3-11-2010\esami.cpp In member function `std::string studente::getNomeEsame(int)': 106 C:\Users\Neptune\Desktop\Asd\laboratorio\3-11-2010\esami.cpp conversion from `<unknown type>' to non-scalar type `std::string' requested C:\Users\Neptune\Desktop\Asd\laboratorio\3-11-2010\Makefile.win [Build Error] [esami.o] Error 1
la linea 106 si riferisce al metodo subito dopo, ovvero a studente::getNomeEsame, dove anche qui non fa altro che ritornare "esami[num_es].getEsame; ".
Non riesco prorpio a capire che sono quei due errori perchè i tipi sembrano essere tutti giusti e non riesco a riscontrare altri generi di errori.
Vi ringrazio in anticipo per ogni eventuale aiuto,
Neptune.


Rispondi quotando
