- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7346 Articles for C++
![Vrundesha Joshi](https://www.tutorialspoint.com/assets/profiles/13566/profile/60_88163-1512715024.jpg)
130 Views
iswalnum() function in C++ STL checks if the given wide character is an alphanumeric character, i.e. either a number (0-9), an uppercase letter(A-Z), a lowercase letter (a-z) or any alphanumeric character or not.AlgorithmBegin Initializes the characters. Call function iswalnum(c1) to check whether it is alphanumeric or not. If it is alphanumeric character, then value will be returned otherwise zero will be returned. EndExample Code#include #include using namespace std; int main() { wchar_t c1 = '/'; wchar_t c2 = 'a'; if (iswalnum(c1)) wcout
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
737 Views
InsertionInsertion in STL set can be done by insert() and emplace() operation.Insert(): Insert() is used to insert elements to the set. Insert operation takes a reference to an object.List of functions are used:st.size() = Returns the size of set. st.insert() = It is used to insert elements to the set.Example Code#include #include #include #include using namespace std; int main() { set st; set::iterator it; int c, i; while (1) { cout
![Nitya Raut](https://www.tutorialspoint.com/assets/profiles/13573/profile/60_92249-1512715559.jpg)
585 Views
Erase function is used to remove an item from a C++ STL vector with a certain value.AlgorithmBegin Declare vector v and iterator it to the vector. Initialize the vector. Erase() function is used to remove item from end. Print the remaining elements. End.Example Code#include #include using namespace std; int main() { vector v{ 6,7,8,9,10}; vector::iterator it; it = v.end(); it--; v.erase(it); for (auto it = v.begin(); it != v.end(); ++it) cout
![Vrundesha Joshi](https://www.tutorialspoint.com/assets/profiles/13566/profile/60_88163-1512715024.jpg)
988 Views
emplace operation avoids unnecessary copy of object and does the insertion more efficiently than insert operation. Insert operation takes a reference to an object.AlgorithmBegin Declare set. Use emplace() to insert pair. Use insert() to insert pair by using emplace(). Print the set. EndExample Code#include using namespace std; int main() { set s; s.emplace(7, 'a'); s.insert(make_pair(6, 'b')); for (auto it = s.begin(); it != s.end(); ++it) cout
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
3K+ Views
Generally, the default behavior of map and multimap map is to store elements is in ascending order. But we can store element in descending order by using the greater function.The map in descending order:Functions are used here -m::find() – Returns an iterator to the element with key value ‘b’ in the map if found, else returns the iterator to end.m::erase() – Removes the key value from the map.m:: equal_range() – Returns an iterator of pairs. The pair refers to the bounds of a range that includes all the elements in the container which have a key equivalent to key.m insert() ... Read More
![Nitya Raut](https://www.tutorialspoint.com/assets/profiles/13573/profile/60_92249-1512715559.jpg)
405 Views
Vectors have the ability to resize itself automatically like dynamic arrays when an element is inserted or deleted, the container handle their storage automatically. Vector elements are placed in contiguous storage so that they can be accessed and traversed using iterators. Data can be inserted or erased at the begin, middle or end of the vector.Functions and descriptions:List of functions used here: v.size() = Returns the size of vector. v.push_back() = It is used to insert elements to the vector from end. v.pop_back() = To pop out the value from the vector from back. v.capacity() = ... Read More
![Vrundesha Joshi](https://www.tutorialspoint.com/assets/profiles/13566/profile/60_88163-1512715024.jpg)
858 Views
Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be FILO (First In first out) or LIFO (Last In First Out)AlgorithmBegin Declare stack vector. Take the input as per choice. Call the functions within switch operation: s.size() = Returns the size of stack. s.push() = It is used to insert elements to the stack. s.pop() = To pop out the value from the stack. s.top() = Returns a ... Read More
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
127 Views
In this C++ program, we implement Sorting containers in STL.Functions and descriptions:Functions used here: l.push_back() = It is used to push elements into a list from the front. l.sort() = Sorts the elements of the list. Where l is a list object.Example Code#include #include #include #include using namespace std; int main() { list l; list::iterator it; int c, i; while (1) { cout
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
520 Views
The union of two sets is created by the elements that are present in either one of the sets, or in both. Elements from the second set that has the same element in the first set are not copied to the resulting set.Common set operations are −Set UnionSet IntersectionSymmetric Set Difference or Exclusive-ORSet Difference or SubtractionAlgorithmBegin Declare set vector v and iterator st. Initialize st= set_union (set1, set1 + n, set2, set2 +n, v.begin())) Print the elements. End.Example Code Live Demo#include #include #include using namespace std; int main () { int set1[] = {5, ... Read More
![Nitya Raut](https://www.tutorialspoint.com/assets/profiles/13573/profile/60_92249-1512715559.jpg)
196 Views
This is a c++ program to implemet set_symmetric_difference. The symmetric difference of two sets is built by the elements that are present in one of the sets, but not in the other.Common set operations are −Set UnionSet IntersectionSymmetric Set Difference or Exclusive-ORSet Difference or SubtractionAlgorithmBegin Declare set vector v and iterator st. Initialize st = set_symmetric_difference (set1, set1 + n, set2, set2 +n, v.begin())) Print the elements obtained after symmetric_difference of two sets End.Example Code#include #include #include using namespace std; int main () { int set1[] = {5, 6, 7, 8, 9, 10}; ... Read More