共用方式為


basic_string::pointer

A type that provides a pointer to a character element in a string or character array.

typedef typename allocator_type::pointer pointer;

Remarks

The type is a synonym for allocator_type::pointer.

For type string, it is equivalent to char*.

Example

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

int main( ) 
{
   using namespace std;
   basic_string<char>::pointer pstr1a = "In Here";
   char *cstr1b = "Out There";
   cout << "The string pstr1a is: " << pstr1a <<  "." << endl;
   cout << "The C-string cstr1b is: " << cstr1b << "." << endl;
}
The string pstr1a is: In Here.
The C-string cstr1b is: Out There.

Requirements

Header: <string>

Namespace: std

See Also

Reference

basic_string Class