Export (0) Print
Expand All
Expand Minimize


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

typedef typename allocator_type::const_pointer const_pointer;

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.

// 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.

Header: <string>

Namespace: std

© 2014 Microsoft