C++ remove element from set
C++
// CHARACTER SET EXAMPLE
// CPP program to illustrate
// Implementation of erase() function
#include <iostream>
#include <set>
using namespace std;
int main()
{
// set declaration
set<char> myset{ 'A', 'C', 'E', 'G' };
set<char>::iterator it1, it2;
// defining it1 pointing to the first
// element and it2 to the last element
it1 = myset.begin();
it2 = myset.end();
// decrementing the it2 two times
it2--;
it2--;
// erasing elements within the
// range of it1 and it2
myset.erase(it1, it2);
// Printing the set
for (auto it = myset.begin();
it != myset.end(); ++it)
cout << ' ' << *it;
return 0;
}
std::set<int> s {1,2,3};
s.erase(2);
Also in C++:
- Title
- object slicing in c++
- Category
- C++
- Title
- for c++
- Category
- C++
- Title
- zeros of array c++
- Category
- C++
- Title
- inserting an element in an set c++
- Category
- C++
- Title
- & in xml
- Category
- C++
- Title
- fail() in c++
- Category
- C++
- Title
- c++ overloaded == operator
- Category
- C++
- Title
- passing reference in c++
- Category
- C++
- Title
- properties of a set c++
- Category
- C++
- Title
- first fit algorithm
- Category
- C++
- Title
- mark occurances of elements in array cpp
- Category
- C++
- Title
- c++ files
- Category
- C++
- Title
- how to convert n space separated integers in c++
- Category
- C++
- Title
- how to iterate through a map in c++
- Category
- C++
- Title
- char **
- Category
- C++
- Title
- map vs unordered_map in C++
- Category
- C++
- Title
- c++ program to find gcd of 3 numbers
- Category
- C++
- Title
- recursion in cpp with reference
- Category
- C++
- Title
- how to sort vector in c++
- Category
- C++
- Title
- how to create object in c++
- Category
- C++
- Title
- how to use assrt c++
- Category
- C++
- Title
- error: invalid conversion from 'Node*' to 'int'
- Category
- C++
- Title
- c++ string to stream
- Category
- C++
- Title
- how to include seld declared header file in c++
- Category
- C++
- Title
- counting valleys hackerrank solution in c++
- Category
- C++
- Title
- sorting of array in c++
- Category
- C++
- Title
- int to float c++
- Category
- C++
- Title
- spicoli
- Category
- C++
- Title
- deque c++
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- qt make widget ignore mouse events
- Category
- C++
- Title
- initialise 2d vector in c++
- Category
- C++
- Title
- c++ parse int
- Category
- C++
- Title
- newline in c++
- Category
- C++
- Title
- map insert c++
- Category
- C++
- Title
- range based for loop c++ with reference
- Category
- C++
- Title
- c++ loop through int array
- Category
- C++
- Title
- c++ excel cell blank cells
- Category
- C++
- Title
- c++ compiler for sublime text
- Category
- C++
- Title
- hello world c++
- Category
- C++
- Title
- error: ‘memset’ was not declared in this scope in cpp
- Category
- C++
- Title
- matrix multiplication c++ eigen
- Category
- C++
- Title
- hashmap in c++
- Category
- C++
- Title
- findung the mode in c++
- Category
- C++
- Title
- C++ and endl
- Category
- C++
- Title
- differentialble programming
- Category
- C++
- Title
- error: redefinition of ‘class Customer’
- Category
- C++
- Title
- COnvert string to char * C++
- Category
- C++
- Title
- c++ iterate over vector
- Category
- C++
- Title
- how to convert string into number
- Category
- C++
- Title
- how to sort in descending order c++
- Category
- C++
- Title
- c++ code for polynomial addition
- Category
- C++
- Title
- c++ set add element
- Category
- C++
- Title
- c++ find prime numbers
- Category
- C++
- Title
- cin.ignore
- Category
- C++
- Title
- jump to case label c++
- Category
- C++
- Title
- set in c++
- Category
- C++
- Title
- time function c++
- Category
- C++
- Title
- C++ Student::Student()
- Category
- C++
- Title
- cube mapping sdl
- Category
- C++
- Title
- sfml basic program
- Category
- C++
- Title
- c++ tutorial
- Category
- C++
- Title
- friend function in c++
- Category
- C++
- Title
- find all occurrences of a substring in a string c++
- Category
- C++
- Title
- compile c++ program
- Category
- C++
- Title
- vector concat c++
- Category
- C++
- Title
- c++ how to make a negative float positive
- Category
- C++
- Title
- c++ reverse vector
- Category
- C++
- Title
- worker class c++
- Category
- C++
- Title
- size of a matrix c++
- Category
- C++
- Title
- repeating character in c++
- Category
- C++
- Title
- bool function in c++
- Category
- C++
- Title
- translate
- Category
- C++
- Title
- can we compare a long long int with int in c++ using max or min functions
- Category
- C++
- Title
- c++ pi
- Category
- C++
- Title
- if vector contains value c++
- Category
- C++
- Title
- adding element in vector c++
- Category
- C++
- Title
- what is time complexity of insertion sort
- Category
- C++
- Title
- glfw initialize in c++
- Category
- C++
- Title
- how to show c++ binary files in sublime text
- Category
- C++
- Title
- c++ read file line by line
- Category
- C++
- Title
- how to concatinate two strings in c++
- Category
- C++
- Title
- how to measure program run time in c++
- Category
- C++
- Title
- c++ round to int
- Category
- C++
- Title
- How to traverse in a tree iterative C++
- Category
- C++
- Title
- how to iterate through array in c++
- Category
- C++
- Title
- double to float c++
- Category
- C++
- Title
- what does map.count() return in c++
- Category
- C++
- Title
- class is replace by structure
- Category
- C++
- Title
- ternary search c++
- Category
- C++
- Title
- pyqt connect
- Category
- C++
- Title
- c++ overload operator
- Category
- C++
- Title
- opperanf >> c++
- Category
- C++
- Title
- private and public in namespace cpp
- Category
- C++
- Title
- how to iterate over unordered_map c++
- Category
- C++
- Title
- tokenize string c++
- Category
- C++
- Title
- restting a queue stl
- Category
- C++
- Title
- iostream library in cpp
- Category
- C++
- Title
- how to append an element to an array in cpp
- Category
- C++
- Title
- how print fload wiht 3 decimal in c++
- Category
- C++