basic_string::const_pointer

A type that provides a pointer to a const element in a string.

typedef typename allocator_type::const_pointer const_pointer;

Remarks

The type is a synonym for allocator_type::const_pointer.

For type string, it is equivalent to char*.

Pointers that are declared const must be initialized when they are declared. Const pointers always point to the same memory location and may point to constant or nonconstant data.

Example

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

int main( ) 
{
   using namespace std;
   basic_string<char>::const_pointer pstr1a = "In Here";
   const char *cstr1c = "Out There";

   cout << "The string pstr1a is: " << pstr1a <<  "." << endl;
   cout << "The C-string cstr1c is: " << cstr1c << "." << endl;
}
The string pstr1a is: In Here.
The C-string cstr1c is: Out There.

Requirements

Header: <string>

Namespace: std

See Also

Reference

basic_string Class