Jan 2, 2020 in C Plus Plus
Q:

Delegating Constructors

1 Answer

0 votes
Jan 2, 2020

In C++11 a constructor may call another constructor of the same class:

class M //C++11 delegating constructors

{

int x, y;

char *p;

public:

M(int v) : x(v), y(0), p(new char [MAX]) {} //#1 target

M(): M(0) {cout<<"delegating ctor"<<endl;} //#2 delegating

};

Constructor #2, the delegating constructor, invokes the target constructor #1.

Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
Jan 2, 2020 in C Plus Plus
+1 vote
...