ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل Mahmoud Manaa , Network Engineer , Zain - Kuwait
تاريخ النشر: 2013/09/30
Mahmoud DEHAINI
من قبل 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
من قبل 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
من قبل 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
من قبل 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.

مستخدم محذوف‎
من قبل مستخدم محذوف‎

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.

المزيد من الأسئلة المماثلة