Skip to content

Tag Archives: cpp-constructor

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
Prerequisite : Constructors A constructor is a special member function of a class which initializes objects of a class. In C++, constructor is automatically called… Read More
Prerequisites: Constructors in C++ In C++, We can have more than one constructor in a class with same name, as long as each has a different… Read More
Prerequisite – Constructors in C++ What is the output of following program? #include <iostream> using namespace std;    class construct {      int a, b; public: … Read More