Register now or log in to join your professional community.
the constructor will create and manipulate all the field of an object. It can do all the necessary treatment also..... the benefit is the following: ur are not forced to repeat all the manipulation and treatment of field in each time u want to create an object.... the constructor will handle all the necessary work
A method that do not have a return type and the name of the method is as same as class name are basically called as constructor. Reason behind to define a constructor is to make default implementation.
Constructors are invoked as soon as the class object is instantiated.
Constructors can either be default [without parameters] or Parameterised one.
A constructor resembles an instance method with no explicit return types. Constructors often have the same name as the declaring class. They have the task of initializing the object's data members.
Class constructors are Class constructors & Benifits behind are the benifits we take out of it :)Note: It seems that questioning module on Bayt.com is far different than the one we have on CodeProject. Make it worthful by asking some real-life issues rather to ask bookish questions regarding which you can get better answered on google.
A class constructor is a method that executes automatically when creating a object instance. The advantages of using them is that you can preset some atributes of the object when you instance it and perform other operations.
In object oriented programming, any class should have a class constructor and destructor. There are a lot of benefits. Within the class constructor, you need to assign a default values for any defined variables, also you can assign and allocate a memory for any dynamic defined variables related to this class. The destructor, used to deallocate the allocated assigned dynamic variables. You need to do that for a better system coding security.