Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What's the class constructor and what's benefits behind it ?

user-image
Question ajoutée par Mahmoud Manaa , Network Engineer , Zain - Kuwait
Date de publication: 2013/09/30
Mahmoud DEHAINI
par Mahmoud DEHAINI , Software Engineer , Mediatechnix

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

Lokesh Gajbhiye
par Lokesh Gajbhiye , Software Programmer , Datacomp Web Technologies (India) Pvt. Ltd

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.

Yameen Mohammed Khan
par Yameen Mohammed Khan , IT Manager , Al Faisal Medical Center

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.

Zubair Ali
par Zubair Ali , Software Developer III , S&P Global

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.

Utilisateur supprimé
par Utilisateur supprimé

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.

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?