+3 votes
in Class 11 by kratos

When a compiler can automatically generate a constructor if it is not defined then why is it considered that writing constructor for a class is a good practice?

1 Answer

+3 votes
by kratos
 
Best answer

When an object of the class is created a compiler can automatically generates a constructor if it is not defined. It is considered that writing constructor for a class is a good practice because constructor takes over very important duty of initialization of an object being created and relieves us from this task.

...