次の方法で共有


operator+ (<string>)

2 文字列オブジェクトを連結します。

template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator> operator+(
      const basic_string<CharType, Traits, Allocator>& _Left,
      const basic_string<CharType, Traits, Allocator>& _Right
   );
template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator> operator+(
      const basic_string<CharType, Traits, Allocator>& _Left,
      const CharType* _Right
   );
template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator> operator+(
      const basic_string<CharType, Traits, Allocator>& _Left,
      const CharType _Right
   );
template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator> operator+(
      const CharType* _Left,
      const basic_string<CharType, Traits, Allocator>& _Right
   );
template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator> operator+(
      const CharType _Left,
      const basic_string<CharType, Traits, Allocator>& _Right
   );
template<class CharType, class Traits, class Allocator>
    basic_string<CharType, Traits, Allocator>&& operator+(
        const basic_string<CharType, Traits, Allocator>& _Left,
        const basic_string<CharType, Traits, Allocator>&& _Right
);
template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator>&& operator+(
      const basic_string<CharType, Traits, Allocator>&& _Left,
      const basic_string<CharType, Traits, Allocator>& _Right
);
template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator>&& operator+(
      const basic_string<CharType, Traits, Allocator>&& _Left,
      const basic_string<CharType, Traits, Allocator>&& _Right
);
template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator>&& operator+(
      const basic_string<CharType, Traits, Allocator>&& _Left,
      const CharType *_Right
);
template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator>&& operator+(
      const basic_string<CharType, Traits, Allocator>&& _Left,
      CharType _Right
);
template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator>&& operator+(
      const CharType *_Left,
      const basic_string<CharType, Traits, Allocator>&& _Right
);
template<class CharType, class Traits, class Allocator>
   basic_string<CharType, Traits, Allocator>&& operator+(
      CharType _Left,
      const basic_string<CharType, Traits, Allocator>&& _Right
);

パラメーター

  • _Left
    basic_string の C. の文字列を連結するオブジェクト。

  • _Right
    basic_string の C. の文字列を連結するオブジェクト。

戻り値

入力文字列の連結を示す文字列。

解説

関数テンプレート クラス basic_string Class の 2 個のオブジェクトを連結する各オーバーロード operator+。すべての効果的に basic_string<CharType 特性 アロケーター > _Left () を返します。追加します。(_Right)。

使用例

// string_op_con.cpp
// compile with: /EHsc
#include <string>
#include <iostream>

int main( ) 
{
   using namespace std;
   // Declaring an object of type basic_string<char>
   string s1 ( "anti" );
   string s2 ( "gravity" );
   cout << "The basic_string s1 = " << s1 << "." << endl;
   cout << "The basic_string s2 = " << s2 << "." << endl;

   // Declaring a C-style string
   char *s3 = "heroine";
   cout << "The C-style string s3 = " << s3 << "." << endl;

   // Declaring a character constant
   char c1 = '!';
   cout << "The character constant c1 = " << c1 << "." << endl;

   // First member function: concatenates an  object
   // of type basic_string with an object of type basic_string
   string s12 = s1 + s2;
   cout << "The string concatenating s1 & s2 is: " << s12 << endl;

   // Second & fourth member functions: concatenate an object
   // of type basic_string with an object of C-syle string type
   string s1s3 = s1 + s3;
   cout << "The string concatenating s1 & s3 is: " << s1s3 << endl;

   // Third & fifth member functions: concatenate an object
   // of type basic_string with a character constant
   string s1s3c1 = s1s3 + c1;
   cout << "The string concatenating s1 & s3 is: " << s1s3c1 << endl;
}
  
  
  
  
  

必要条件

ヘッダー : <string>

名前空間: std

参照

関連項目

basic_string Class

<string>

string::operator+

その他の技術情報

basic_string メンバー

<string> メンバー