C++ 字串庫 - rend



描述

它返回一個反向迭代器,指向反向結尾。

宣告

以下是 std::string::rend 的宣告。

reverse_iterator rend();
const_reverse_iterator rend() const;

C++11

reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;

引數

返回值

它返回一個反向迭代器,指向字串的反向結尾。

異常

從不丟擲任何異常。

示例

以下為 std::string::rend 的示例。

#include <iostream>
#include <string>

int main () {
   std::string str ("Tutorials Point...");
   for (std::string::reverse_iterator rit=str.rbegin(); rit!=str.rend(); ++rit)
      std::cout << *rit;
   return 0;
}

示例輸出應如下所示:

...tnioP slairotuT 
string.htm
廣告

© . All rights reserved.