Frage zu ostream / istream
-
Hi !
1.Als erstes ich habe gerade probleme damit
in der klasse:friend ostream &operator <<(ostream &o,const Bruch &b); Bruch ostream &operator <<(ostream &o,const Bruch &b) { o <<"Bruch ist"<<b.m_zaehler<<"_"b.m_nenner; return o; }
Das geht leider nicht ich weiß nicht warum
2.Mal ne andere frage wenn man eine Abgeleitete Klasse hat und in der operatoren überladen möchte, ist das möglich ?
Vielen dank Frank
-
friend ostream &operator <<(ostream &o,const Bruch &b); ostream &operator <<(ostream &o,const Bruch &b) // <--- Kein Bruch vor ostream { o <<"Bruch ist"<<b.m_zaehler<<"_"b.m_nenner; return o; }
-
Danke ostream geht !
Aber ich weiß nicht wie ich den istream mache kann mir da jmd helfen bitte?
Klasse: ostream &operator<<(istream &i,Bruch &b) Oder so ostream &operator>>(istream &i,Bruch &b) und wie muss ich dann den code schreiben ? ostream &operator>>(istream &i,Bruch &b) { int x,y; i >> x; }
Danke
-