In C++, deep copy and shallow copy are two different approaches to copying objects. Shallow Copy: A shallow copy creates a new object and copies the values of the members from the original object to the new object. If the Read More …
Author: admin2
Why copy constructor use pass by reference only not pointer?
In C++, when designing a copy constructor, it is common to pass the argument by reference rather than by pointer. This is because passing by reference allows for cleaner syntax and avoids unnecessary null pointer checks. Additionally, passing by reference Read More …
What is Interface Class?
In C++, an interface class is a class that defines a contract or a set of pure virtual functions without any member variables. It serves as a blueprint for other classes to inherit from and implement the required functionality. An Read More …
What is Abstract Class?
In C++, an abstract class is a class that cannot be instantiated directly, meaning you cannot create objects of that class. It is designed to serve as a base class for other classes and defines a common interface that its Read More …
What is Pure virtual functions?
In C++, a pure virtual function is a function that has no implementation within the base class. It is declared using the “virtual” keyword followed by “= 0” in its declaration. The purpose of a pure virtual function is to Read More …
What is the difference between a pointer and a reference in C++?
In C++, both pointers and references are used to indirectly access objects or variables. However, there are some key differences between them. Let’s explore these differences with examples: 2. Syntax and Usage: 3. Nullability: 4. Reassignment: It’s worth noting that Read More …
What is a virtual function in C++ and how does it work?
In C++, a virtual function is a member function of a base class that can be overridden in a derived class. It enables dynamic polymorphism, allowing different objects to be treated as objects of the base class while invoking the Read More …
What is object-oriented programming (OOP) and how is it implemented in C++?
C++ OOP’s supports the four main principles : encapsulation, inheritance, polymorphism, and abstraction. Encapsulation In this example, we have defined a class BankAccount that represents a simple bank account. The private member variable balance stores the current balance of the Read More …
Types of Violations and Rotations in AVL Tree
An AVL tree is a self-balancing binary search tree where the balance factor of every node is kept within a specific range to ensure that the tree remains balanced. In an AVL tree, the balance factor of every node must Read More …
AVL(Adelson-Velskii and Landis) Tree
AVL Tree is the extended version of Binary Search Tree(BST), and also AVL Tree remove the disadvantage of Binary Search Tree(BST).In BST worst Time complexity for searching is O(n). and also in worst case BST is also not an balanced Read More …