Bitte nochmals um Hilfe



  • Hier ist nochmal der von mir geschriebenen Quelltext:
    Mein Problem liegt in main(), weil ich pro Patienten mehrere Termine anlegen muss.

    Grüße
    Eddy

    C/C++ Code:
    #include <iostream>
    #include <vector>
    #include <string>
    #include <fstream>
    using namespace std;

    class cZeit // Class cZeit !!!!!!!!!!!!!!!!
    {
    friend istream& operator>>(istream& out, cZeit& Z);
    friend ostream& operator<<(ostream& in, cZeit& Z);

    private:
    int _hour;
    int _min;

    public:
    cZeit () { _hour=0; _min=0;}; //Konstruktor
    cZeit (int h, int m)
    {_hour = h;
    _min = m;
    }; //Konstruktor

    int gethour(){ return _hour;}
    int getmin (){ return _min; }
    void anzeigen()
    {
    cout<<_hour<<':'<<_min;
    }
    };

    class cDatum
    {
    friend istream& operator>>(istream& out, cDatum& D);
    friend ostream& operator<<(ostream& in, cDatum& D);
    private:
    int _tag;
    int _monat;
    int _jahr;
    public:
    cDatum (int t, int m, int j)
    { _tag = t; _monat = m; _jahr = j;}

    cDatum (){_tag = 0; _monat = 0; _jahr = 0;}

    void datausgeben ()
    { cout<<_tag<<":"<<_monat<<":"<<_jahr;}
    };

    class cPatient
    {
    friend istream& operator>>(istream& out, cPatient& P);
    friend ostream& operator<<(ostream& in, cPatient& P);
    private:
    string _name;
    int _nummer;
    public:
    void anlegen()
    {
    cout<<"Name: "; cin>>_name;
    cout<<"Patientennummer: "; cin>>_nummer;
    }
    };

    class cTermin
    {
    private:
    cDatum date;
    cZeit time;
    cPatient Patient;
    string Leistung;

    public:

    void patientanlegen()
    { cout<<"Name und Patientennummer des Patienten eingeben:";
    cin>>Patient;
    }

    void terminanlegen()
    {
    cin>>date;
    cin>>time;
    cout<<"Name der Leistung: ";cin>>Leistung;
    }

    void ausgeben()
    {
    cout<<Patient;
    cout<<date;
    cout<<time;
    cout<<"Leistung: "<<Leistung;
    }
    };

    int main ()
    {
    int anzahl;
    cout<<"wie viele Patienten sollen angelegt werden??: ";
    cin>>anzahl;
    vector<cTermin> VT(anzahl);

    for(int i=0; i<anzahl; ++i) //Hier liegt mein Problem
    {VT[i].patientanlegen(); //Ich muss für einen Patienten mehrere
    VT[i].terminanlegen();} //Termine anlegen können.
    for(int i=0; i<anzahl; ++i)
    {VT[i].ausgeben();}

    system("Pause");
    return 0;
    }

    //*************** >> Patient*************************
    istream& operator>>(istream& out, cPatient& P)
    {
    cout<<"Bitte den Namen eingeben: ";
    out>>P._name;
    cout<<"Patienten Nummer: ";
    out>>P._nummer;
    return out;
    }
    ostream& operator<<(ostream& in, cPatient& P)
    {
    cout<<"Name:"<<P._name<<"\tPatienten Nummer:"<<P._nummer<<endl;
    return in;
    }
    //*********************************************************

    istream& operator>>(istream& out, cDatum& D)
    {
    cout<<"Bitte den Tag, Monat und das Jahr eingeben";
    cin>>D._tag>>D._monat>>D._jahr;
    return out;
    }
    ostream& operator<<(ostream& in, cDatum& D)
    {
    cout<<"Datum : "<<D._tag<<"."<<D._monat<<"."<<D._jahr<<endl;
    return in;
    }

    //******************************************************************

    istream& operator>>(istream& out, cZeit& Z)
    {
    cout<<"Bitte Anfangsstunde und Anfangsminute eingeben: ";
    cin>>Z._hour>>Z._min;
    return out;
    }

    ostream& operator<<(ostream& in, cZeit& Z)
    {
    cout<<"Zeit: "<<Z._hour<<":"<<Z._min<<endl;
    return in;
    }



  • ja ruf einfach die terminanlegen() Methode mehr mals an





  • Einmal reicht.


Anmelden zum Antworten