The rule of three in C++ states that, if a class in C++ has any one (or more) of the following, then it should define all three. Destructor Copy Constructor Copy Assignment Constructor These three are special member functions of class and are responsible for managing resources such as dynamic memory, file handles, sockets, etc. And if one of them is defined explicitly, means that class is managing those resources manually (like memory using new/delete), and if we fail to define others then it can lead to ... Read More
In this section we will see when we declare a variable that is un-initialized, then which value they hold in C or C++ language.What Happens When You Don’t Initialize Variables? In C and C++, when a variable is declared inside a function (i.e., as a local variable) but not explicitly initialized, it holds an undefined or garbage value. This means the variable may contain any value that is present at that memory location.Unlike some high-level languages where variables are automatically initialized (e.g., 0 for integers, false for booleans), C and C++ do not initialize local variables by default. So, assuming ... Read More
C++ Volatile KeywordIn C++, the volatile keyword is a type qualifier that tells the compiler that the value of a variable may be changed at any time unexpectedly, so it should not optimize access to that variable. This change in a variable may be influenced by any external factors such as hardware, signal handlers, or concurrent threads. This concept of volatile is mostly used when working with systems programming, embedded systems, and multi-threaded applications. SyntaxHere, a variable is declared volatile, which means the compiler volatile data_type variable_name; Example This example represents a variable whose value may be changed from an external source. ... Read More
In Python, a list is a built-in data structure that is used to store an ordered collection of multiple items in a single variable. Lists are mutable that means we can add, remove, and change its elements. In this article, we will learn how we can add the corresponding elements of two Python Lists. You are given two equal sized lists in Python and your task is to create a new list containing sum of corresponding elements of the lists.Consider the following input output scenario:Scenario Input: List1 = [3, 6, 9, 45, 6] List2 = [11, 14, 21, ... Read More
The Depth First Search (DFS) algorithm can be used to check whether a graph is bipartite by coloring the graph using two colors. This section will discuss how DFS traversal can be used to check if a graph is bipartite. First of all, let's understand what a bipartite graph is. What is Bipartite Graph? A bipartite graph is a special type of graph where you can divide the vertices into two sets, such that no two vertices of the same set are connected. This is why it's possible to color a bipartite graph using just two colors. Technically, a ... Read More
In Python, tuples are used to store immutable sequence of elements. A nested tuple is a tuple that contains one or more tuples as their elements. For example: # A tuple in Python tup = ( 1, 2, 3, 4 ) # A nested tuple in Python nestedTup = ( (1, 2), (3, 4) ) You are given two nested tuples in Python, and your task is to add corresponding elements of those tuples.Consider the following example scenario:Scenario Input tuples: tup1 = ((7, 8), (3, 4), (3, 2)) tup2 = ((9, 6), (8, 2), (1, 4)) ... Read More
In Python, tuples are used to store an immutable sequence of elements. In this article, we will learn different methods to implement a Python program to add corresponding elements of tuples. Here, you are given two equally sized tuples in Python and your task is to create a new tuple containing sum of corresponding elements of the tuples. Consider the following example scenario:Scenario Input Tuples: tup1 = (3, 6, 9, 45, 6) tup2 = (11, 14, 21, 0, 6) Output: (14, 20, 30, 45, 12 ) Explanation: The corresponding elements that are added to get ... Read More
Encapsulation Encapsulation is one of the four fundamental OOPs concepts. The other three are inheritance, polymorphism, and abstraction.Encapsulation in Java is a mechanism for wrapping the data (variables) and the code acting on the data (methods) together as a single unit. In encapsulation, the variables and methods within a class are hidden using the private access specifier (though it's not mandatory for all variables and methods to be private). This is known as data hiding.To access private variables and methods from other classes, one of the simplest ways is by using getter and setter methods. ... Read More
In this article, we will learn about the new methods added to the Process API in Java 9. First, we will know about what is process API, and the methods in Process API in detail. What is Process API? In Java, the Process API, we can perform any operation regarding a process. If one must get the process ID of currently running process, or to create a new process, or destroy an already running one, or find child and parent processes of currently running process, or just get any information about a process, then the Process API is used to perform ... Read More
In C and C++, every function is stored in the computer's memory, and each function has a memory address just like all other variables. In this article, our task is to see how we can access the address of a function and display it in both C and C++. Accessing Address of a Function To access the address of a function, we simply use its name without parentheses. When we print a function name with parentheses like hello(), we're calling the function. But if we print just hello, it gives us the memory address where the function is stored. ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP