Skip to content

Tag Archives: cpp-constructor

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++   1. What is the output of following program?   CPP #include <iostream> using namespace std;   class construct {     int a,… Read More
A pure virtual destructor can be declared in C++. After a destructor has been created as a pure virtual object(instance of a class), where the… Read More
A constructor is a special member function that is automatically called by the compiler when an object is created and the destructor is also a… Read More
Pre-requisite: Constructor in C++  A copy constructor is a member function that initializes an object using another object of the same class. In simple terms,… Read More
Prerequisite: Static Keyword in C++ An object becomes static when a static keyword is used in its declaration. Static objects are initialized only once and… Read More
Constructor in C++ is a special method that is invoked automatically at the time of object creation. It is used to initialize the data members… Read More
The problem is to create a class such that the non-dynamic allocation of object causes compiler error. For example, create a class ‘Test’ with following… Read More
When we create our own copy constructor, we pass an object by reference and we generally pass it as a const reference. One reason for passing… Read More
A constructor is a special type of member function of a class that initializes objects of a class. In C++, Constructor is automatically called when… Read More
A copy constructor is a member function that initializes an object using another object of the same class. The Copy constructor is called mainly when… Read More