We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: User

Using std::find & std::find_if with User Defined Classes

std::find and std::find_if algorithms are used to find first element in the given range. In this article we will see how to use std::find and std::find_if algorithm with user defined datatypes i.e. Classes & Structures. Advertisements Internally std::find algorithm uses the == operator for comparisons. For built-in data types like int, std::string etc operator == …

Using std::find & std::find_if with User Defined ClassesRead More

Be careful with hidden cost of std::vector for user defined objects

output_1

While creating and using std::vector with user defined classes we needs some special care otherwise it can hamper the performance of our application. [showads ad=inside_post] Let’s learn by example, Suppose we have an Item Class, Advertisements class Item { public: static int m_ConstructorCalledCount; static int m_DestCalledCount; static int m_CopyConstructorCalledCount; Item() { m_ConstructorCalledCount++; } ~Item() { …

Be careful with hidden cost of std::vector for user defined objectsRead More

C++ : Map Tutorial Part 3: Using User defined class objects as keys in std::map

In this article we will discuss how to use User defined classes as key in std::map. By default std::map uses “operator <” as sorting criteria for keys. For default data types like int and std::string etc, operator < is available by default but for User defined classes operator < is not available by default. Advertisements …

C++ : Map Tutorial Part 3: Using User defined class objects as keys in std::mapRead More

C++ std::set example and tutorial with user defined classes

In this article we will see how to use std::set with user defined classes. If you want to use std::set with user defined classes and use default sorting criteria then overload operator < in the class. Advertisements For example, Suppose our class is Message that contains three properties i.e. • Member content • Sending User …

C++ std::set example and tutorial with user defined classesRead More

Importance of Constructors while using User Defined Objects with std::vector

For User Defined classes if Copy Constructor and Assignment Operator are public then only one can insert it’s object in std::vector. This is because of two reasons, Advertisements All STL contains always stores the copy of inserted objects not the actual one. So, whenever we insert any element or object in    container then it’s …

Importance of Constructors while using User Defined Objects with std::vectorRead More

Iterating over a range of User Defined objects and calling member function using std::for_each

In this article we will discuss how to iterate over a container of user defined objects and call a member function on each of the iterating element.Suppose you have a vector of Employee class objects and you want to call a member function on each of the element in vector. [showads ad=inside_post] Let’s see how …

Iterating over a range of User Defined objects and calling member function using std::for_eachRead More

How to use Unordered_set with User defined classes – Tutorial & Example

In this article we will discuss how to use std::unordered_set with User defined classes. std::unordered_set internally implements a hash table to store the elements. To know more about Hash Table visit the following article, What is Hashing and Hash Table? Advertisements std::unordered_set uses the hasher and comparison function. For primitive data types like int, string etc. default …

How to use Unordered_set with User defined classes – Tutorial & ExampleRead More

Prompt for user input & read command-line arguments in Python

In this Python tutorial, we will learn how to prompt for user input and read command-line arguments in Python Programming language. This enhances the productivity and functionality, when we can directly take the input from user while executing the program. Table Of Contents Introduction User Input Method 1 : Using the Sys module Method 2 …

Prompt for user input & read command-line arguments in PythonRead More

Cart

Your Cart is Empty

Back To Shop