Create a string object using another string object. - C++ STL

C++ examples for STL:string

Description

Create a string object using another string object.

Demo Code

#include <iostream>
#include <string>
using namespace std;
int main()//from w  w w  . ja  v a2 s  . c  o  m
{
   string str1("Alpha");
   string str2("Beta");
   string str3("Gamma");
   string str4;
   str4 = str1 + str3;
   cout << "Initialize str5 with the contents of str1.\n";
   string str5(str1);
   cout << "str5: " << str5 << "\n\n";
   return 0;
}

Result


Related Tutorials