Next: new und delete statt
Up: 50 Ways to Improve
Previous: const und inline statt
Die Funktionen aus stdio.h können auch in C++ Programmen
benutzt werden, aber
- sie sind nicht typsicher
- sie sind nicht erweiterbar
- sie erfordern die Trennung von Formatierungsangabe und Daten
(Fortran-Stil der 60er Jahre).
Die Stärken von <<
und >>
:
- Erweiterbarkeit durch Überladen:
int i;
mycomplex c;
cin >> i >> c;
cout << "Complex: " << c;
- Ein- und Ausgabe hat die gleiche syntaktische Form:
int i;
char *pc;
scanf("%d %s",&i,pc);
...
cin >> i >> pc;
Next: new und delete statt
Up: 50 Ways to Improve
Previous: const und inline statt
Peter Pfahler, 1997