We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: Initialize

Different Ways to Initialize a vector in C++

In this article we will discuss different ways to initialize a std::vector in C++. Initializing std::vector elements with same value std::vector<int> vec_1(5, 10); It will create a vector of 5 element and initialize  each element is initialized to 10. Advertisements Initializing std::vector elements with passed argument list std::vector<int> vec_2 = {10,20,30,40,50}; It will create a vector of 5 …

Different Ways to Initialize a vector in C++Read More

5 Different ways to Initialize a vector in c++

In this article we will discuss different ways to initialize a vector in C++. Creating a vector object without any initialization will create an empty vector with no elements i.e. Advertisements std::vector<int> vecOfInts; But we generally want to initialize a vector with huge values and calling push_back() that many times to add element in vector is not an …

5 Different ways to Initialize a vector in c++Read More

Different ways to Initialize a list in C++

In this article we will discuss the different ways to initialize a std::list in C++. std::list provides various overloaded constructors for creation and initialization of list. Let’s see different ways to create & initialize a std::list in C++ i.e. Advertisements Creating an Empty List in C++ std::list has a default constructor that will create an empty …

Different ways to Initialize a list in C++Read More

Different Ways to initialize an unordered_map

In this article we will discuss the different ways to initialize an unordered_map. unordered_map provides different overloaded constructors. We will use some of them to initialize an unordered_set in 3 different ways i.e. Initializing through an initializer_list Initializing through a iterable range. Initializing through an another map. Lets see them in detail, Advertisements Initializing an unordered_map …

Different Ways to initialize an unordered_mapRead More

Using std::initializer_list in constructors to initialize member variables

In this article we will discuss how to use std::initializer_list<T> to initialize member variables. Suppose we have a class Point that has 3 member variables representing x, y & Z axis coordinates. It has a parameterized constructor too i.e. Advertisements class Point { int mX; int mY; int mZ; public: Point(int a, int b, int …

Using std::initializer_list in constructors to initialize member variablesRead More

C++ : How to Initialize a map in one line using initialzer_list ?

In this article we will discuss how to initialize a map with std::initialzer_list<T>. Let’s create a map of string as key and int as value and initialize it with initializer_list i.e. Advertisements // Initialize a Map of string & int using initializer_list std::map<std::string, int> mapOfMarks = { {“Riti”,2}, {“Jack”,4} }; Here compiler will create following …

C++ : How to Initialize a map in one line using initialzer_list ?Read More

Python : How to create a list and initialize with same values

In this article we will discuss how to create a list and initialise with same values. Creating a list of same values by [] and multiply Suppose we want to create a list of strings, which contains 20 same strings i.e. ‘Hi’ Advertisements [‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, ‘Hi’, …

Python : How to create a list and initialize with same valuesRead More

Create Numpy Array of different shapes & initialize with identical values using numpy.full() in Python

In this article we will discuss how to create a Numpy Array of different shapes and initialized with same identical values using numpy.full(). numpy.full() Python’s Numpy module provides a function to create a numpy array of given shape and all elements initialized with a given value, Advertisements numpy.full(shape, fill_value, dtype=None, order=’C’) Arguments:shape: Shape of the …

Create Numpy Array of different shapes & initialize with identical values using numpy.full() in PythonRead More

Cart

Your Cart is Empty

Back To Shop