- 1
Why to use constructors?
What's the reason to use constructors when that make the same things of the object properties?
4 Answers
+ 2
constructors can initialize your class/struct object while they are being created...
0
if u want something compulsory like you have a class for doing database activities and connection is required compulsory the you can add that into constructor.
0
to initialize the members of the class i mean (data of your class)
- 2
when you create a object of class with new keyword that time it call constructor may be you declared as explicitly or if not then compiler take care for declared implicitly constructor for initialization default value of all variables of class.