+ 1
So when are constructors usually used?
1 Answer
+ 3
When you need to initialize your object to some known state to start with or perform procedure before the object can be used. Let's say you want to teach someone how to drive. Before the driving lesson could start, you first need a car with gas. So you can get a car in constructor and fill gas in it. As a user, they came to your school just for learning but there are other requirements which user assume you fulfil it.