174k views
2 votes
In object-oriented programming, what is a constructor?

1 Answer

7 votes

A constructor in object-oriented programming is a special method of a class or structure that initializes an object of that type. Basically, it resembles an instance method that usually has the same name as the class. In simple terms, it is a subroutine called to create an object.






User Shiva Avula
by
6.3k points