Constructor: – It is a special member function which is use to allocate the memory for the object.

Whenever the object will be created or declare, immediately the constructor will be called. If we have not taken any constructor then compiler will automatically create default constructor with empty body inside public section of class.

Syntax: – To create the constructor

                Class_Name(Parameter List)
                                {
                                _ _ _ _ _
                                _ _ _ _ _
                                }

Ex: –

                Demo()
                                {
                                _ _ _ _ _
                                _ _ _ _ _
                                }
Advertisements