Found 7347 Articles for C++

deque push_back( ) in C++ in STL

Sunidhi Bansal
Updated on 26-Feb-2020 11:22:30

184 Views

Given is the task to show the functionality of deque push_back( ) function in C++ STLWhat is DequeDeque is the Double Ended Queues that are the sequence containers which provides the functionality of expansion and contraction on both the ends. A queue data structure allow user to insert data only at the END and delete data from the FRONT. Let’s take the analogy of queues at bus stops where the person can be inserted to a queue from the END only and the person standing in the FRONT is the first to be removed whereas in Double ended queue the ... Read More

list insert( ) in C++ STL

Sunidhi Bansal
Updated on 26-Feb-2020 11:10:18

9K+ Views

Given is the task to show the functionality list insert( ) function in C++ in STL.What is List in STLList are containers that allow constant time insertion and deletion anywhere in sequence. List are implemented as doubly linked lists. List allow non-contiguous memory allocation. List perform better insertion extraction and moving of element in any position in container than array, vector and deque. In List the direct access to the element is slow and list is similar to forward_list, but forward list objects are single linked lists and they can only be iterated forwards.What is insert( )The list insert( ) ... Read More

deque_resize( ) in C++ in STL

Sunidhi Bansal
Updated on 26-Feb-2020 11:03:42

175 Views

Given is the task to show the functionality of deque resize( ) function in C++ STL.What is DequeDeque is the Double Ended Queues that are the sequence containers which provides the functionality of expansion and contraction on both the ends. A queue data structure allow user to insert data only at the END and delete data from the FRONT. Let’s take the analogy of queues at bus stops where the person can be inserted to a queue from the END only and the person standing in the FRONT is the first to be removed whereas in Double ended queue the ... Read More

list unique( ) in C++ STL

Sunidhi Bansal
Updated on 26-Feb-2020 10:55:05

271 Views

Given is the task to show the functionality list unique( ) function in C++ in STL.What is List in STLList are containers that allow constant time insertion and deletion anywhere in sequence. List are implemented as doubly linked lists. List allow non-contiguous memory allocation. List perform better insertion extraction and moving of element in any position in container than array, vector and deque. In List the direct access to the element is slow and list is similar to forward_list, but forward list objects are single linked lists and they can only be iterated forwards.What is unique( )The list unique( ) ... Read More

list begin( ) and list end( ) in C++ STL

Sunidhi Bansal
Updated on 26-Feb-2020 10:47:14

449 Views

Given is the task to show the functionality list begin( ) and list end( ) function in C++ in STL.What is List in STLList is a data structure that allows constant time insertion and deletion anywhere in sequence. Lists are implemented as doubly linked lists. Lists allow non-contiguous memory allocation. List perform better insertion extraction and moving of element in any position in container than array, vector and deque. In List the direct access to the element is slow and list is similar to forward_list, but forward list objects are single linked lists and they can only be iterated forwards.What ... Read More

How to convert a class to another class type in C++?

Ayush Gupta
Updated on 25-Feb-2020 09:15:13

4K+ Views

In this tutorial, we will be discussing a program to understand how to convert a class to another class type in C/C++.Class conversion can be done with the help of operator overloading. This allows data of one class type to be assigned to the object of another class type.Example Live Demo#include using namespace std; //type to which it will be converted class Class_type_one {    string a = "TutorialsPoint";    public:       string get_string(){          return (a);    }    void display(){       cout

How to find the sum of elements of a Vector using STL in C++?

Ayush Gupta
Updated on 25-Feb-2020 09:12:10

598 Views

In this tutorial, we will be discussing a program to understand how to find the sum of elements of a vector using STL in C++.To find the sum of elements of a given vector, we would be using the accumulate() method from the STL library.Example Live Demo#include using namespace std; int main(){    //defining the vector    vector a = { 1, 45, 54, 71, 76, 12 };    cout

How to find the maximum element of a Vector using STL in C++?

Ayush Gupta
Updated on 25-Feb-2020 08:08:29

6K+ Views

In this tutorial, we will be discussing a program to understand how to find the maximum element of a vector using STL in C++.To find the maximum element from a given vector, we will be using the *max_element() method from STL library.Example Live Demo#include using namespace std; int main(){    //defining the vector    vector a = { 1, 45, 54, 71, 76, 12 };    cout

How to find common elements between two Vectors using STL in C++?

Ayush Gupta
Updated on 25-Feb-2020 08:05:48

746 Views

In this tutorial, we will be discussing a program to understand how to find common elements between two vectors using STL in C++.To find the common elements between two given vectors we will be using the set_intersetion() method.Example Live Demo#include using namespace std; int main(){    //defining the vectors    vector vector1 = { 1, 45, 54, 71, 76, 12 };    vector vector2 = { 1, 7, 5, 4, 6, 12 };    sort(vector1.begin(), vector1.end());    sort(vector2.begin(), vector2.end());    cout

How to find common elements between two Arrays using STL in C++?

Ayush Gupta
Updated on 25-Feb-2020 07:59:32

209 Views

In this tutorial, we will be discussing a program to understand how to find common elements between two arrays using STL in C++.To find the common elements between two given arrays we will be using the set_intersetion() method.Example Live Demo#include using namespace std; int main(){    //defining the array    int arr1[] = { 1, 45, 54, 71, 76, 12 };    int arr2[] = { 1, 7, 5, 4, 6, 12 };    int n1 = sizeof(arr1) / sizeof(arr1[0]);    int n2 = sizeof(arr2) / sizeof(arr2[0]);    sort(arr1, arr1 + n1);    sort(arr2, arr2 + n2);    cout

Advertisements