Ayush Gupta has Published 527 Articles

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

Ayush Gupta

Ayush Gupta

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

5K+ 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 ... Read More

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

Ayush Gupta

Ayush Gupta

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

877 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; ... Read More

How to create an unordered_set of user defined class or struct in C++?

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:49:36

845 Views

In this tutorial, we will be discussing a program to understand how to create an unordered set of user defined class or struct in C++.For this we will create a structure type and then compare two structure types with the function defined by the user to store the hash function.Example#include ... Read More

How to create an unordered_map of user defined class in C++?

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:36:24

633 Views

In this tutorial, we will be discussing a program to understand how to create an unordered map of user defined class in C++.To create an unordered map from a user defined class, we will pass the hash function as the class method being the third argument.Example Live Demo#include using namespace ... Read More

How to create an unordered_map of pairs in C++?

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:31:23

981 Views

In this tutorial, we will be discussing a program to understand how to create an unordered map of pairs in C++.Unordered maps are the ones that don't contain hash function for the pairs by default. If we want a hash value for a particular pair, it needs to be passed ... Read More

How to create a List with Constructor in C++ STL

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:28:17

269 Views

In this tutorial, we will be discussing a program to understand how to create a List with constructor in C++ STL.List are data structures to store elements in memory in a non-contiguous fashion. They are insertion and deletion quick as compared to vectors.Example Live Demo#include #include using namespace std; ... Read More

How to add “graphics.h” C/C++ library to gcc compiler in Linux

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:25:35

2K+ Views

In this tutorial, we will be discussing a program to understand how to add “graphics.h” C/C++ library to gcc compiler in Linux.To do this we are required to compile and install the libgraph package.This includes install build-essential and some external packages>>sudo apt-get install build-essential >>sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev ... Read More

How does a vector work in C/C++

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:20:01

3K+ Views

In this tutorial, we will be discussing a program to understand how vectors work in C/C++.A vector data structure is an enhancement over the standard arrays. Unlike arrays, which have their size fixed when they are defined; vectors can be resized easily according to the requirement of the user.This provides ... Read More

Count all sub-sequences having product <= K – Recursive approach in C++

Ayush Gupta

Ayush Gupta

Updated on 17-Feb-2020 10:49:05

247 Views

In this tutorial, we will be discussing a program to find the number of sub-sequences having product k) {       discard_count += power(2, n - i);       return;    }    if (i == n)       return;       float rem = ... Read More

Count all possible walks from a source to a destination with exactly k edges in C++

Ayush Gupta

Ayush Gupta

Updated on 17-Feb-2020 10:45:04

172 Views

In this tutorial, we will be discussing a program to find the number of walks from a source to a destination with exactly k edges.For this we will be provided with a graph and the values of source and destination. Our task is to find all the possible paths starting ... Read More

Advertisements