string::operator<<
說明如何使用 string::operator << Visual C++ 標準樣板程式庫 (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);
備註
![]() |
---|
在原型中的類別/參數名稱不相符的標頭檔中的版本。某些已修改以提高可讀性。 |
運算子 << 用來將字串插入至輸出資料流。
範例
// 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>