+ 1
What is CONSTRUCTOR used for? And, actually, what is it?
4 Antworten
+ 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.
+ 2
When u do make a instance of a class. A function is called which is called CONSTRUCTOR
+ 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
+ 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.