Aracılığıyla paylaş


basic_string::difference_type

Aynı dize öğelerinin başvuran iki Yineleyicilerde arasındaki fark sağlayan bir türü.

typedef typename allocator_type::difference_type difference_type;

Notlar

Denetlenen sıradaki iki herhangi bir öğenin adresler arasındaki farkı gösteren bir nesne imzalı tamsayı türü açıklanmaktadır.

Yazıda dize, eşdeğeri olan ptrdiff_t.

Örnek

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

int main( ) 
{
   using namespace std;
   string str1 ( "quintillion" );
   cout << "The original string str1 is: " << str1 << endl;
   basic_string <char>::size_type indexChFi, indexChLi;

   indexChFi = str1.find_first_of ( "i" );
   indexChLi = str1.find_last_of ( "i" );
   basic_string<char>::difference_type diffi = indexChLi - indexChFi;

   cout << "The first character i is at position: "
        << indexChFi << "." << endl;
   cout << "The last character i is at position: "
        << indexChLi << "." << endl;
   cout << "The difference is: " << diffi << "." << endl;
}
  
  
  

Gereksinimler

Başlık: <string>

Namespace: std

Ayrıca bkz.

Başvuru

basic_string Class