Category Archives

Virtual Copy Constructor

In the virtual constructor idiom we have seen the way to construct an object whose type is not determined...

Virtual Copy Constructor

In the virtual constructor idiom we have seen the way to construct an object whose type is not determined...

Virtual Constructor

Can we make a class constructor virtual in C++ to create polymorphic objects? No. C++ being statically typed (the...

Virtual Constructor

Can we make a class constructor virtual in C++ to create polymorphic objects? No. C++ being statically typed (the...

Copy elision in C++

Copy elision (or Copy omission) is a compiler optimization technique that avoids unnecessary copying of objects. Now a days,...

Copy elision in C++

Copy elision (or Copy omission) is a compiler optimization technique that avoids unnecessary copying of objects. Now a days,...

Playing with Destructors in C++

Predict the output of the below code snippet. #include <iostream> using namespace std; int i; class A { public:...

Playing with Destructors in C++

Predict the output of the below code snippet. #include <iostream> using namespace std; int i; class A { public:...

Private Destructor

Also read : Can a constructor be private in C++ ? Predict the output of following programs. // CPP...

Private Destructor

Also read : Can a constructor be private in C++ ? Predict the output of following programs. // CPP...

Default Constructors

A constructor without any arguments or with default value for every argument, is said to be default constructor. What...

Default Constructors

A constructor without any arguments or with default value for every argument, is said to be default constructor. What...

When do we use Initializer List in C++?

Initializer List is used in initializing the data members of a class. The list of members to be initialized...

When do we use Initializer List in C++?

Initializer List is used in initializing the data members of a class. The list of members to be initialized...

Initialization of data members

In C++, class variables are initialized in the same order as they appear in the class declaration. Consider the...

Initialization of data members

In C++, class variables are initialized in the same order as they appear in the class declaration. Consider the...

When is copy constructor called?

In C++, a Copy Constructor may be called in following cases: 1. When an object of the class is...

When is copy constructor called?

In C++, a Copy Constructor may be called in following cases: 1. When an object of the class is...

When should we write our own copy constructor?

C++ compiler provide default copy constructor (and assignment operator) with class. When we don’t provide implementation of copy constructor...

When should we write our own copy constructor?

C++ compiler provide default copy constructor (and assignment operator) with class. When we don’t provide implementation of copy constructor...