Ich bin mir ziemlich sicher, dass ich den Code für die beiden Funktionen in meiner Klasse falsch geschrieben habe. Ich bin verwirrt, wie man nur die zwei Stücke der Daten richtig (x und y) aufnimmt und stellt sicher, dass sie in einem guten Zustand sind.Confused So stellen Sie sicher, dass die Daten in IOStream "gut" sind
/**
* Requires: ins is in good state.
* Modifies: ins, x, y.
* Effects: Reads point in form (x,y).
*/
void read(istream& ins);
/**
* Requires: outs is in good state.
* Modifies: outs.
* Effects: Writes point in form (x,y).
*/
void write(ostream& outs);
void Point::read(istream& ins) {
char junk;
char junk2;
char junk3;
while (cin.good()) {
cin >> junk >> x >> junk2 >> y >> junk3;
}
}
void Point::write(ostream& outs) {
while (cout.good()) {
cout << "(" << x << "," << y << ")";
}
}
Was ist 'x' und' y'? –
Sie sind die Punkte in einer Koordinate (x, y). – NICE8xxx
Ah ha. Du hast mich jetzt vollkommen erleuchtet. Veröffentlichen Sie bitte ein [MCVE], das Ihr tatsächliches Problem nach Bedarf wiedergibt? –