Salve, solo voi potete farmi da tutor.
per esercizio ho dovuto creare un oggetto student, e uno student_club, come segue:
codice:#include <iostream> #include <string> using namespace std; /*------------------------------------------------Class student---------------*/ class Student { public: Student(); Student(string student_name, string major_at_acceptance); void set_major(string new_major); string get_major() const; string get_name() const; void set_name(string new_name); private: string name; string major; }; Student::Student() { name = ""; major = ""; } Student::Student(string student_name, string major_at_acceptance) { name=student_name; major=major_at_acceptance; } void Student::set_major(string new_major) { major = new_major; } void Student::set_name(string new_name) { name = new_name; } string Student::get_major() const { return major; } string Student::get_name() const { return name; } /*----------------------------------------------------------------------------*/ /*--------------------------class Student Club--------------------------------*/ class student_club {public: student_club(); student_club(string club_name); string get_name() const; void set_president(Student* a); string get_president() const; void set_secretary(Student* b); string get_secretary() const; private: string name; string President; string Vicepresident; string Secretary; string Treasurer; }; student_club::student_club() {} student_club::student_club(string club_name) { name=club_name; } string student_club::get_name() const { return name; } void student_club::set_president(Student* c) { President = c->get_name(); } string student_club::get_president() const { return President; } void student_club::set_secretary(Student* b) { Secretary=b->get_name(); } string student_club::get_secretary() const { return Secretary; } /*----------------------------------------------------------------------------*/ int main(void) { Student* AAAA= new Student("Pippo Paperino","scienze"); Student* AAAB= new Student("Braccobaldo Bau","Lettere"); Student* AAAC= new Student("Piffo Paffo","Ingegnerie"); student_club* scacchi = new student_club("Schacci"); student_club* bridge = new student_club("bridge club"); scacchi->set_president(AAAA); scacchi->set_secretary(AAAC); bridge->set_president(AAAB); bridge->set_secretary(AAAA); cout<<"il club è : "<<scacchi->get_name()<<'\n'; cout<<"il presidente è : "<<scacchi->get_president()<<'\n'; cout<<"che essendo primcipalmente studente frequenta "<<AAAA->get_major()<<'\n'; cout<<"ci sono due club : "<<'\n'; cout<<scacchi->get_name()<<" e "<<bridge->get_name()<<'\n'; cout<<"il presidente di scacchi è : "<<scacchi->get_president()<<'\n'; cout<<"il segretario di scacchi è : "<<scacchi->get_secretary()<<'\n'; cout<<"il presidente di bridge è : "<<bridge->get_president()<<'\n'; cout<<"il segretario di bridge è : "<<bridge->get_secretary()<<'\n'; cout<<"codeste persone studiano anche in : "<<AAAA->get_major()<<" "<<AAAB->get_major() <<" "<<AAAC->get_major()<<'\n'; system("PAUSE"); return 0; }
ora devo fare un ulteriore esercizio:
Usando la classe Student_Club class creata in P3, si aggiunga un campo addizionale,
members, costituito da un array di puntatori a oggetti di tipo Student.
MI date una mano??
Il campo members, devo passarlo nel costruttore? tipo :
e poi nella definizione del costruttore come lo inizializzo??codice:student_club(string club_name, Student* members[]);
Grazie mille a tutti.

Rispondi quotando
