+ 1

What is CONSTRUCTOR used for? And, actually, what is it?

18th Dec 2016, 8:53 AM
Nochains
Nochains - avatar
4 ответов
+ 2
constructors are used during the initialization of a new object. when you create a new object in the facts you call its constructor. in the class the constructor may not be defined. in this case the class would not assign internal values (or would assign only default values); otherwise you are free to define a constructor with one or more parameters that are passed when you initiate the object. pay attention because if you define a constructor with parameters the default constructor will be always available until you define it as private. NB: constructors cannot return a value.
18th Dec 2016, 9:35 AM
Michael Isac Girardi
Michael Isac Girardi - avatar
+ 2
When u do make a instance of a class. A function is called which is called CONSTRUCTOR
18th Dec 2016, 4:01 PM
Saksham
Saksham - avatar
+ 1
constructor is used when making objects constructor is function which is called to create objects it is called when an object is made by class which has constructor. constructor is used to run codes of setting the properties of the object creat
18th Dec 2016, 9:14 AM
Sandeep Chatterjee
+ 1
It is run automatically when object is created. It is used for ex. for variables declaration, file opening, screen initialization, declaration of consts or anything you need to do to prepare your object to use.
18th Dec 2016, 10:33 AM
Adam Emieljaniuk
Adam Emieljaniuk - avatar