1 / 3

Constructor

Constructor . It is a special member of a class that has the following characteristic It has the same name as of its class . It don’t have an explicit return type . It is implicitly invoke when object is created, it uses to initialized to data member of an object.

rehan
Download Presentation

Constructor

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Constructor It is a special member of a class that has the following characteristic It has the same name as of its class . It don’t have an explicit return type . It is implicitly invoke when object is created, it uses to initialized to data member of an object. Note: if a class does not have any constructor then default constructor (constructor without arguments) provided by the compiler at the time of compilation but if a class contains an argumented constructor & there is an object of the class that requires default constructor for initialization then default constructor has to be define in the class .this time it won’t be given by the compiler.

  2. Note: if a class contains multiple implementation of a constructor or a method then constructor or the method is said to be overloded.different implementations of an overloaded construtor and method are differentiated either by varying there are no. of arguments ,by varying their types of arguments. • Method or constructor overloading is one of the means to implements polymorphism. To provide the facility to the end user.

  3. Anonyms Block • An Anonyms block is a block without any identifier . It is used to specified common code of all constructor i.e. statement of anonyms block are placed in constructor body by the compiler at compilation time.

More Related