Skip to content

Tag Archives: cpp-constructor

A constructor is a special type of member function whose task is to initialize the objects of its class. It has no return type so… Read More
Constructor is a class member function with the same name as the class. The main job of the constructor is to allocate memory for class… Read More
Constructor is a class member function with the same name as the class. The main job of the constructor is to allocate memory for class… Read More
In this article, we will discuss the Dynamic initialization of objects using Dynamic Constructors. Dynamic initialization of object refers to initializing the objects at a… Read More
In general, creating a copy of an object means to create an exact replica of the object having the same literal value, data type, and… Read More
In Object Oriented Programming, Objects are the instances of a class which has its own state(variables) and behavior(methods).  Every class has two special methods related… Read More
Prerequisites: l-value and r-value references in C++, Copy Constructor in C++. What is a Move Constructor?   The copy constructors in C++ work with the… Read More
When allocation of memory is done dynamically using dynamic memory allocator new in a constructor, it is known as dynamic constructor. By using this, we… Read More
The answer to this question depends upon 2 scenarios: Scenario 1: When there is a Virtual function in the program: In this scenario, compiler automatically… Read More
How to print “Hello” N times (where N is user input) without using loop or recursion or goto. Input : N, that represent the number… Read More
1. What is destructor? Ans. Destructor is a member function which is called when an object is deleted/destroyed or goes out of scope. class String… Read More
Defaulted Function What is a Defaulted Function? Explicitly defaulted function declaration is a new form of function declaration that is introduced into the C++11 standard which… Read More
Sometimes it is useful for a constructor to be able to call another constructor of the same class. This feature, called Constructor Delegation, was introduced… Read More
Many times, user wants that an instance of a C++ class should not be copied at all. So, the question is how do we achieve… Read More
This rule basically states that if a class defines one (or more) of the following, it should explicitly define all three, which are: destructor copy… Read More

Start Your Coding Journey Now!