📌  相关文章
📜  c++代码示例中集合的最后一个元素

📅  最后修改于: 2022-03-11 14:44:46.692000             🧑  作者: Mango

代码示例2
set st {1,2,3,4};

// rbegin() meand reverse begin, means we will choose the first element
// from the end of the set (start counting from the end)
auto last (st.rbegin()); //get iterator of the first element from the end
cout << *last << endl; //get the value from the iterator (return 4)

// instead we could directly use :
cout << *(st.rbegin()) << endl; // return 4