string::operator<<
Visual C++ で String:: operator<< の標準テンプレート ライブラリ関数を使用する方法に (STL) ついて説明します。
template<class _E, class _TYPE, class _A> inline
basic_ostream<_E, _TYPE>&
operator<<( basic_ostream<_E, _TYPE>& OStream,
const basic_string<_E, _TYPE, _A>& XString);
解説
[!メモ]
プロトタイプのクラスやパラメーター名はヘッダー ファイルのバージョンと一致しない。ただし読みやすさが向上するように変更されました。
operator<< が出力ストリームに文字列を挿入するために使用されます。
使用例
// StringInsertion.cpp
// compile with: /EHsc
// Illustrates how to use the insertion operator
// (operator<<) to insert a string into an output
// stream.
//
// Functions:
//
// operator<< Inserts a string into an output stream.
//////////////////////////////////////////////////////////////////////
#pragma warning(disable:4786)
#include <string>
#include <iostream>
using namespace std ;
int main()
{
string msg="Hello! This is the insertion operator.";
cout << msg << endl;
}
必要条件
ヘッダー : <string>