basic_string::const_pointer

提供了指向字符串中的一个 const 元素的类型。

typedef typename allocator_type::const_pointer const_pointer;

备注

该类型是 allocator_type::const_pointer的同义词。

对于类型 字符串,它与 char等效于*。

声明常数的指针必须初始化,在声明它们时。Const指针始终指向同一内存位置,并且可以指向常数或用非常数数据。

示例

// 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;
}
  
  

要求

标头: <string>

命名空间: std

请参见

参考

basic_string Class