Found 7197 Articles for C++

transform_inclusive_scan() function in C++

Ayush Gupta
Updated on 12-Mar-2020 06:19:56

79 Views

In this tutorial, we will be discussing a program to understand the transform_inclusive_scan() function in C++.Example Live Demo#include #include using namespace std; namespace point_input_iterator {    template    OutputItrator transform_inclusive_scan(InputItrator first,       InputItrator last,       OutputItrator d_first,       BinaryOperation binary_op,       UnaryOperation unary_op){             *d_first = unary_op(*first);       first++;       d_first++;       for (auto it = first; it != last; it++) {          //calculating the prefix sum          *d_first = binary_op(unary_op(*it), *(d_first ... Read More

Thread get_id() function in C++

Ayush Gupta
Updated on 12-Mar-2020 06:15:40

194 Views

In this tutorial, we will be discussing a program to understand thread get_id() function in C++.Thread get_id() function verifies the current state of the process and then returns the id for the current thread in execution. This function doesn’t take any parameters.Example#include #include #include using namespace std; //creating thread void sleepThread(){    this_thread::sleep_for(chrono::seconds(1)); } int main(){    thread thread1(sleepThread);    thread thread2(sleepThread);    thread::id t1_id = thread1.get_id();    thread::id t2_id = thread2.get_id();    cout

Containership in C++

Ayush Gupta
Updated on 12-Mar-2020 06:08:55

2K+ Views

In this tutorial, we will be discussing a program to understand containership in C++.The parameter if a certain class contains another class is called as containership. The inside class is called contained class, while the class in which it is present is called container class.Example Live Demo#include using namespace std; class first {    public:    first(){       cout

Containers in C++ STL

sudhir sharma
Updated on 29-May-2024 13:11:59

1K+ Views

The C++ STL (Standard Template Library) is a powerful set of C++ template classes to provide general-purpose classes and functions with templates that implement many popular and commonly used algorithms and data structures like vectors, lists, queues, and stacks.It is a library of container classes, algorithms, and iterators. It is a generalized library and so, its components are parameterized. Working knowledge of template classes is a prerequisite for working with STL.Templates are a feature of the C++ programming language that allows functions and classes to operate with generic types. This allows a function or class to work on many different ... Read More

Constructors in C++ Programming

Ayush Gupta
Updated on 12-Mar-2020 06:02:08

654 Views

In this tutorial, we will be discussing a program to understand constructors in C++.Constructors are member functions of the classes which initiates the object instance creation. They have the same name as the parent class and don’t have any return type.Default constructorsExample Live Demo#include using namespace std; class construct {    public:    int a, b;    //default constructor    construct(){       a = 10;       b = 20;    } }; int main(){    construct c;    cout

forward_list::clear() and forward_list::erase_after() in C++ STL

Sunidhi Bansal
Updated on 06-Mar-2020 07:37:29

442 Views

In this article we will be discussing the working, syntax and examples of forward_list::clear() and forward_list::erase_after() functions in C++.What is a Forward_list in STL?Forward list are sequence containers that allow constant time insert and erase operations anywhere within the sequence. Forward lists are implemented as singly linked lists. The ordering is kept by the association to each element of a link to the next element in the sequence.What is forward_list::clear()?forward_list::clear() is an inbuilt function in C++ STL which is declared in header file. clear() is used when we have to remove all the elements of the forward list at ... Read More

list::push_front() and list::push_back() in C++ STL

Sunidhi Bansal
Updated on 06-Mar-2020 07:35:10

4K+ Views

In this article we will be discussing the working, syntax and examples of list::push_front() and list::push_back() functions in C++ STL.What is a List in STL?List 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 performs 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 ... Read More

list::pop_front() and list::pop_back() in C++ STL

Sunidhi Bansal
Updated on 06-Mar-2020 07:32:36

537 Views

In this article we will be discussing the working, syntax and examples of list::pop_front() and list::pop_back() functions in C++ STL.What is a List in STL?List 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 performs 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 ... Read More

list::front() and list::back() in C++ STL

Sunidhi Bansal
Updated on 06-Mar-2020 07:30:01

3K+ Views

In this article we will be discussing the working, syntax and examples of list::front() and list::back() functions in C++ STL.What is a List in STL?List 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 performs 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 ... Read More

list splice() function in C++ STL

Sunidhi Bansal
Updated on 06-Mar-2020 07:27:02

613 Views

In this article we will be discussing the working, syntax and examples of list::splice() function in C++ STL.What is a List in STL?List 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 performs 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 ... Read More

Advertisements