These three constructors have the same function body. The duplicated codes make maintenance difficult. If you want to add more members or change the type of existing members, you have to make the same changes three times. To avoid code duplication, some programmers move the common initialization steps to a member function. The constructors achieve the same function by calling this member function. Let us revise the example as follows:
class A{
public:
A(): num1(0), num2(0) {init();}
A(int i): num1(i), num2(0) {init();}
A(int i, int j): num1(i), num2(j) {init();}
private:
int num1;
int num2;
int average;
void init(){ average=(num1+num2)/2;};
};

This revision eliminates code duplication but it brings the following new problems:

After we enter a class member function, all the class members have already been constructed. It's too late to call member functions to do the construction work of class members.

C++11 proposed a new feature called delegating constructors to solve this existing problem. You can concentrate common initialization steps in a constructor, known as the target constructor. Other constructors can call the target constructor to do the initialization. These constructors are called delegating constructors. Let us use this new feature for the program above:

You can see that delegating constructors make the program clear and simple. In this example, A() delegates to A(int i), so A(int i) is the target constructor of A(). A(int i) delegates to A(int i, int j), so A(int i, int j) is the target constructor of A(int i). Delegating and target constructors do not need special labels or disposals to be delegating or target constructors. They have the same interfaces as other constructors. As you haven seen from the example, a delegating constructor can be the target constructor of another delegating constructor, forming a delegating chain. Target constructors are chosen by overload resolution or template argument deduction. In the delegating process, delegating constructors get control back and do individual operations after their target constructors exit. See the following example:
#include <iostream>
using namespace std;

In the preceding example, a recursive chain of delegation exists in the program. The program is ill-formed.

One thing we need to keep in mind is that delegating constructors cannot have initializations of class members in their initializer lists; that is, a constructor cannot delegate and intialize at the same time. For example:
class A{
public:
A(): A(0), average(0){}
A(int i): A(i, 0){}
A(int i, int j) {
num1=i;
num2=j;
average=(num1+num2)/2;
}
private:
int num1;
int num2;
int average;
};
In this example, A() delegates to A(int i) and intializes class member average at the same time, which is not allowed.

If an exception occurs in the body of a target constructor, it can be caught by the try block of the delegating constructor. The following example demonstrates this rule:
#include <iostream>
using namespace std;