Horje
last element of a set in c++ Code Example
how to get last element of set in c++
set<int> s = {1,2,3}
auto it = s.end();
it--;
cout<<*it<<"\n"; // This refers to last element of a set
last element of a set in c++
set<int> 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




Cpp

Related
simple interest rate Code Example simple interest rate Code Example
delete node from linked list Code Example delete node from linked list Code Example
how to test if char in = to another in c++ Code Example how to test if char in = to another in c++ Code Example
cpprestsdk send file Code Example cpprestsdk send file Code Example
c++ vs c# Code Example c++ vs c# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8