Tag: operator
How does new and delete operator works internally ?
In this article we will discuss how new and delete operator works internally in C++.new operator is used to dynamically allocate memory on heap and delete operator is used to delete the memory from the heap allocated by new operator. Usage example of new and delete operator is as follows, #include <iostream> class Sample { …
How does new and delete operator works internally ?Read More
what’s placement new operator and why do we need it.
In this article we will discuss what is placement new operator and what’s its need. Need of placement new operator Every when we create a new object using new operator, memory is allocated on heap i.e. Advertisements int * ptr = new int; But there might be scenarios when we want to dynamically create an …
what’s placement new operator and why do we need it.Read More
C++ Map : Operator [] – Usage Details
In this article we will discuss how to use operator [] with map in C++. std::map has Operator[] i.e. Advertisements mapped_type& operator[] (const key_type& k); operator [] works in Find or Create Mode i.e. when called with a key K, it will try to look for element with given key K and can go in …
Unary Operator Overloading in C++ using both member & Friend function
In this article we will discuss how to overload unary operators in c++ using both member and Friend function. What is an unary operator? An Unary operator is an operator that operates on a single operand and returns a new value. Advertisements Some of the unary operators are, ++ (Increment Operator) —   (Decrement operator) –    (Unary …
Unary Operator Overloading in C++ using both member & Friend functionRead More
Need of Operator Overloading in C++ ? | Tutorial and Examples
In this article we will discuss what is operator overloading in C++, why do we need it and how to overload an operator for a user defined class. What is Operator overloading ? Operator Overloading means providing multiple definition for the same operator. Advertisements For example, using + operator with two integers will add the …
Need of Operator Overloading in C++ ? | Tutorial and ExamplesRead More
C++ : How to get element by index in vector | at() vs operator []
In this article we will discuss different techniques to get an element from vector by index or position. In vector elements are indexed from 0 to size() – 1. To access any element in vector by index vector provides two member functions i.e. at() operator[] Let’s discuss them in detail, Advertisements Access an element in …
C++ : How to get element by index in vector | at() vs operator []Read More
Python : How to Compare Strings ? | Ignore case | regex | is vs == operator
In this article we will discuss different ways to compare strings in python like, using == operator (with or without ignoring case) or using is operator or using regex. Python provides various operators to compare strings i.e. +, !=, <, >, <=, >=. When used for comparison these operators return Boolean True or False value. …
Python : How to Compare Strings ? | Ignore case | regex | is vs == operatorRead More
How to Reverse a 1D & 2D numpy array using np.flip() and [] operator in Python
In this article we will discuss different ways to reverse the contents of 1D and 2D numpy array ( columns & rows ) using np.flip() and [] operator. Reverse 1D Numpy array using [] operator trick First of all import numpy module i.e. Advertisements import numpy as np Now suppose we have a numpy array …
How to Reverse a 1D & 2D numpy array using np.flip() and [] operator in PythonRead More
Pandas : Check if a value exists in a DataFrame using in & not in operator | isin()
In this article we will dicuss different ways to check if a given value exists in the dataframe or not. First of all, we need to import the pandas module i.e. Advertisements import pandas as pd Let’s create a dataframe, # List of Tuples empoyees = [(‘jack’, 34, ‘Sydney’, 155) , (‘Riti’, 31, ‘Delhi’ , …
Pandas : Check if a value exists in a DataFrame using in & not in operator | isin()Read More
Python: if-else in one line – ( A Ternary operator )
In this article, we will learn how to use if-else in one line in python. Other programming languages like C++ and Java have ternary operators, which are useful to make decision making in a single line. Python does not have a ternary operator. But in python, we can use the if-else in a single line, …
Python: if-else in one line – ( A Ternary operator )Read More