Export (0) Print
Expand All

string (<string>) 

A type that describes a specialization of the template class basic_string with elements of type char as a string.


typedef basic_string<char> string;

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

int main( ) 
{
   using namespace std;

   // Equivalent ways to declare an object 
   // of type basic_string <char>
   const basic_string <char> s1 ( "test" );
   string s2 ( "test" );   // Uses the typedef for string

   // comparison between two objects of type basic_string
   if ( s1 == s2 )
      cout << "The strings s1 & s2 are equal." << endl;
   else
      cout << "The strings s1 & s2are not equal." << endl;
}

Output

The strings s1 & s2 are equal.

Header: <string>

Community Additions

ADD
Show:
© 2014 Microsoft