We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: Ways]

C++11 Multithreading – Part 1 : Three Different ways to Create Threads

In this article we will discuss how to create threads in C++11 using std::thread. Introduction to C++11 Thread Library Original C++ Standard supported only single thread programming. The new C++ Standard (referred to as C++11 or C++0x) was published in 2011. In C++11 a new thread library is introduced. Advertisements Compilers Required:  Linux: gcc 4.8.1 …

C++11 Multithreading – Part 1 : Three Different ways to Create ThreadsRead More

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

Different ways to insert elements in an unordered_map

In this article we will discuss the different ways to insert elements in an unordered_map. Unordered_map provides different overloaded versions of insert() member function to insert key value pairs in an unordered_map. Lets discuss them one by one. Advertisements Inserting multiple elements in unordered_map through an initializer_list unordered_map provides an overloaded version of insert that …

Different ways to insert elements in an unordered_mapRead More

C++ : Different ways to insert elements in Set

In this article we will discuss different ways to insert an element in Set. Set provides 3 different overloaded version of insert() function to add element in set. Let’s discuss them one by one, Advertisements Inserting a Single element in Set and checking the result Set is an associative container and contains only unique elements, …

C++ : Different ways to insert elements in SetRead More

Different ways to iterate over a set in C++

In this article we will discuss different ways to iterate over a set in C++. Let’s create a set of strings i.e. Advertisements // Set of strings std::set<std::string> setOfStr = { “jjj”, “khj”, “bca”, “aaa”, “ddd” }; Now let’s iterate over it and print the contents on screen using different methods i.e. Iterating over a …

Different ways to iterate over a set in C++Read More

C++ : Different Ways to iterate over a List of objects

In this article we will discuss different ways to iterate through std::list of objects. Suppose we have a struct Player that contains id and name i.e. Advertisements struct Player { int id; std::string name; Player(int playerId, std::string playerName) : id(playerId), name(playerName) { } }; Lets create a list Player objects i.e. std::list<Player> listofPlayers = { …

C++ : Different Ways to iterate over a List of objectsRead More

Different ways to Erase / Delete an element from a Set in C++

In this article we will discuss different ways to remove an element from Set. std::set provides 3 overloaded version of erase() member function. We will discuss them one by one. Advertisements Suppose we have a set of strings i.e. //Set Of Strings std::set<std::string> setOfStrs = {“Hi”, “Hello”, “is”, “the”, “at”, “Hi”, “is”, “from”, “that”}; Let’s …

Different ways to Erase / Delete an element from a Set in C++Read More

Cart

Your Cart is Empty

Back To Shop