overloaded string concatenation operator : string concatenation « String « C++






overloaded string concatenation operator

  
 

#include <iostream>
using std::cout;
using std::endl;

#include <string>
using std::string;

int main()
{
   string s1( "AA" );
   string s2( " AAB" );
   string s3;

   // 
   cout << "\n\ns1 += s2 yields s1 = ";
   s1 += s2; // test overloaded concatenation
   cout << s1;
   return 0;
}

/* 


s1 += s2 yields s1 = AA AAB
 */        
    
  








Related examples in the same category

1.overloaded string concatenation operator with C-style string
2.Concatenating Strings
3.Concatenate Using STL string