A)
->main purpose of a constructor is to provide initial state to the object. i.e. Constructors are mainly meant for object initialization.
->any resources allocation to the object also can be done in a constructor.
->whatever task you want to perform as soon as the object is created. That code we can plan in a constructor.
Note:
constructor does not construct the object. But without a constructor object can’t be created.
constructor does not construct the object. But without a constructor object can’t be created.
Comments
Post a Comment