What is the role of constructor in classes?

What is the role of a constructor in classes? Explanation: A constructor is used in classes to initialize data members of class in order to avoid errors/segmentation faults .

Sizin İçin Seçtik  Why constructor is used in C++?

Leave a Reply

Your email address will not be published. Required fields are marked *