Anmerkung
Der Zugriff auf diese Seite erfordert eine Genehmigung. Du kannst versuchen, dich anzumelden oder die Verzeichnisse zu wechseln.
Der Zugriff auf diese Seite erfordert eine Genehmigung. Du kannst versuchen , die Verzeichnisse zu wechseln.
Der <ostream> Header stellt die folgenden Operatoren bereit:
operator<<
Schreibt verschiedene Typen in den Stream.
template <class _Elem, class _Tr>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>& _Ostr,
const Elem* str);
template <class _Elem, class _Tr>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>& _Ostr,
Elem _Ch);
template <class _Elem, class _Tr>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>& _Ostr,
const char* str);
template <class _Elem, class _Tr>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>& _Ostr,
char _Ch);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const char* str);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _ostr,
char _Ch);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const signed char* str);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
signed char _Ch);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const unsigned char* str);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
unsigned char _Ch);
template <class _Elem, class _Tr, class T>
basic_ostream <_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>&& _Ostr,
Ty val);
Parameter
_Ch
Ein Zeichen.
_Elem
Der Elementtyp.
_Ostr
Ein basic_ostream-Objekt.
Str
Eine Zeichenfolge.
_Tr
Zeichenmerkmale.
Val
Der Typ
Rückgabewert
Der Datenstrom.
Hinweise
Die basic_ostream-Klasse definiert außerdem mehrere Einfügeoperatoren. Weitere Informationen finden Sie unter basic_ostream::operator<<.
Die Vorlagenfunktion
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _ostr,
const Elem *str);
bestimmt die Länge N = traits_type::length(str) der Sequenz, die bei str beginnt, und fügt die Sequenz ein. Wenn N-Breite<_Ostr., fügt die Funktion auch eine Wiederholung von _Ostr.width - N-Füllzeichen ein. Die Wiederholung steht vor der Sequenz, wenn (_Ostr.
Flags & adjustfield != links. Andernfalls folgt die Wiederholung der Sequenz. Die Funktion gibt _Ostr zurück.
Die Vorlagenfunktion
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
fügt das Element _Ch ein. Wenn 1 <_Ostr.width, fügt die Funktion auch eine Wiederholung von _Ostr.width - 1 Füllzeichen ein. Die Wiederholung geht der Sequenz voraus, wenn ( _Ostr.flags & adjustfield != left. Andernfalls folgt die Wiederholung der Sequenz. Sie gibt _Ostr zurück.
Die Vorlagenfunktion
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const char *str);
verhält sich so
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *str);
außer dass jedes Element _Ch der Sequenz, die bei str beginnt, in ein Objekt vom Typ Elem konvertiert wird, indem put_Ostr.wird.
Die Vorlagenfunktion
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
char _Ch);
verhält sich so
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
außer dass _Ch durch Aufrufen von Aufrufen Elemin ein Objekt vom Typ _Ostr.put( _Ostr.widen( _Ch )) konvertiert wird.
Die Vorlagenfunktion
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const char *str);
verhält sich so
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *str);
(Sie muss die Elemente nicht erweitern, bevor sie eingefügt werden.)
Die Vorlagenfunktion
template <class _Tr>
basic_ostream<char, Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
char _Ch);
verhält sich so
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
(Es muss vor dem Einfügen nicht _Ch erweitert werden.)
Die Vorlagenfunktion
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const signed char *str);
_Ostr << (const char *)str wird zurückgegeben.
Die Vorlagenfunktion
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
signed char _Ch);
_Ostr << (char)_Ch wird zurückgegeben.
Die Vorlagenfunktion:
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const unsigned char *str);
_Ostr << (const char *)str wird zurückgegeben.
Die Vorlagenfunktion:
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
unsigned char _Ch);
_Ostr << (char)_Ch wird zurückgegeben.
Die Vorlagenfunktion:
template <class _Elem, class _Tr, class T>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<char, _Tr>&& _Ostr,
T val);
gibt _Ostr << val zurück (und konvertiert einen RValue-Verweis zu _Ostr zu einem lvalue im Prozess).
Beispiel
Ein Beispiel für die Verwendung von finden Sie unter operator<<.