Uses of Inheriting Constructor

Can someone tell me what is the use of inheriting a constructor in c11.....How does it help us in programming....
Actually you does not inherit a Constructor, It is called Implicitly, there are two types of Constructor 1) default or Zero parameter constructor 2) parameterized constructor. Default constructor are called implicity, but if you have both the constructor(Default, parameterized) the you have to call the second constructor explicitly in the derived class.
closed account (zb0S216C)
prashant gupta wrote:
"Can someone tell me what is the use of inheriting a constructor in c11"

Do you mean delegating constructors (C++11), or do you mean invoking a constructor from a derived class?

Wazzak
The first one......about inheriting constructor from base class in c++11
closed account (zb0S216C)
You cannot inherit constructors, as gurukrupa said. Instead, the appropriate constructor of the base class is called when the base class is built. In C++11, this is still the same, and the only difference, is that you can chain constructor calls (constructor delegation).

Do you mean something like this:

1
2
3
4
5
6
7
8
9
10
11
12
struct Base_Class
{
    // Members...
};

struct Derived_Class : public Base_Class
{
    Derived_Class()
        : Base_Class() // Construct the base class with this constructor.
    {
    }
};

Wazzak
Last edited on
Topic archived. No new replies allowed.